Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trigger HTTP requests on pull-request events from Bitbucket

Ginés Sanchez April 30, 2024

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:

Selection_045.png

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.

1 answer

2 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 1, 2024

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:

  • add the text [skip ci] in the commit messages of the source branch, so that the pull-requests pipeline doesn't get triggered automatically on PR creation or update
  • push an empty commit without [skip ci] to the source branch, whenever you want to trigger the pull-requests pipeline, which in turn can trigger a Jenkins job

Another option would be to develop your own app with Forge, which would allow you to add a pull request action:

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events