Hello,
we are using Bitbucket Server and as part of our build pipeline we have been using the pull-request-notifier-for-bitbucket to trigger http request from Bitbucket to Jenkins in order to invoke custom events.
Basically, that plugins allows us to have custom buttoms in the PR, for example for doing a "Delegate Merge" or "Run Jenkins Build"; and if user selects it, an http request is sent to Jenkins:
The http request params contains parameter like PULL_REQUEST_ID, PULL_REQUEST_FROM_REPO_PROJECT_KEY, PULL_REQUEST_FROM_REPO_NAME, PULL_REQUEST_USER_NAME, PULL_REQUEST_FROM_BRANCH, PULL_REQUEST_TO_BRANCH, PULL_REQUEST_TITLE, PULL_REQUEST_AUTHOR_NAME, PULL_REQUEST_AUTHOR_EMAIL and some others.
There is a fork of that plugin for Bitbucket Datacenter, but there is nothing similar for Bitbucket Cloud. As Atlassian is going not going to provide support for Bitbucket Server anymore, I would like to know if is there any alternative to that plugin for Cloud (Datacenter is very expensive for us).
Or, if is there any other way (if possible from a PR in Bitbucket Cloud) to send an http request with such parameters to Jenkins.
Thanks in advance.
Hi Ginés and welcome to the community!
I did a search in Atlassian Marketplace with search terms 'pull request' and 'Jenkins'
I don't have in-depth knowledge of every single app, but checking their details, none of them seems to offer the option to manually trigger a Jenkins job.
The Webhook to Jenkins for Bitbucket app, as well as the Jenkins plugins for Bitbucket Cloud, seem to be based on webhooks. This means that they trigger a build as soon as an event from the webhook triggers occurs (e.g. pull request created, pull request updated, etc).
Bitbucket's CI/CD tool, Pipelines, can also be used to trigger a job in Jenkins, and pull-requests pipelines have PR-related variables. Pull-requests pipelines also get triggered when a PR is created or updated. However, if you set this up, you could do the following:
Another option would be to develop your own app with Forge, which would allow you to add a pull request action:
Kind regards,
Theodora
Hi @Theodora Boudale, thank you so much fot the update.
We are working to build the plugin (I can see the option we included "Delegate Merge" by selecting the three dots":
and would like to ask you how we can get the next parameters from the PR context in bitbucket cloud, to be included in the Http Request we send to Jenkins.
The parameters we need are:
PULL_REQUEST_FROM_REPO_PROJECT_KEY
PULL_REQUEST_FROM_REPO_NAME
PULL_REQUEST_ID
BUTTON_FORM_DATA
PULL_REQUEST_ID
PULL_REQUEST_FROM_REPO_PROJECT_KEY
PULL_REQUEST_FROM_REPO_NAME
PULL_REQUEST_USER_NAME
PULL_REQUEST_FROM_BRANCH
PULL_REQUEST_TO_BRANCH
PULL_REQUEST_TITLE
PULL_REQUEST_AUTHOR_NAME
PULL_REQUEST_AUTHOR_EMAIL
PULL_REQUEST_DESCRIPTION
By getting them we should be able to trigger an HTTP request to Jenkins like:
Thanks in advance,
Ginés
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ginés,
The pull request ID and the repo UUID are available properties (pullRequest.id and repository.uuid):
I believe you can get most of the other parameters using our API. This API endpoint:
can be used to get the PR's source branch, destination branch, author name, PR title, and PR description. The author email is not returned, we do not return users' email addresses in the API. I'm not sure what you are referring to by BUTTON_FORM_DATA and PULL_REQUEST_USER_NAME?
You can use the following API endpoint to get the repo name and project key:
If you have any other questions specific to app development with Forge, I would recommend posting in the following group (I haven't worked a lot with Forge app development, so the support I can provide is limited):
On the following page, you can also find links to the source code of some example apps for Bitbucket:
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.