Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to trigger a webhook when a commit is pushed to an open pull request branch?

Is there a good way to trigger a webhook from Bitbucket Server whenever a commit is pushed to an open pull request? I am currently using the "Pull Request Opened" webhook event to trigger a CI build (recipient is a Jenkins server), which works well for building newly created PRs. However, there doesn't seem to be an event for when a new commit is pushed to the repository branch that a PR is watching. The "Pull Request Opened" event does not handle this event.

While the Atlassian support page for Bitbucket Server webhooks does not mention this, there is a event for "Pull Request Modified" that is mentioned in a different support page. "Modified" sounds close to what I want, but it doesn't cover a new commit. Here is the description on the Bitbucket Server Webhooks edit page: 

A pull request's description, title, or target branch is changed.

Sure enough, testing with the "Modified" event enabled does not trigger a webhook when a new commit is pushed to a PR branch. I'm starting to think that there are only two other methods:

  1. Trigger a webhook on every push, and have the CI server check to see if that commit is targeting a branch that the Bitbucket Server has an open PR for (using the REST API of Bitbucket Server). This would be undesirable, because the CI server would have to check every new commit, unnecessarily consuming time from the build agents.
  2. Write a post-commit hook onto the Bitbucket server that manually checks for an open PR targeting that commit's branch and writing a POST to a designated URL. I don't know if there's an easy way to do this other than having the hook script call the Bitbucket Server REST API to check for open PRs.

2 answers

1 accepted

0 votes
Answer accepted

It seems that from version 7.0 this feature is build in:

https://jira.atlassian.com/browse/BSERV-10279

We are using version 6.0.1 and not planning fro upgrading soon.

Is there a workaround for it form Atlassian side?

Were you able to find the solution for this issue? I am in exactly the same situation where my open PRs when updated with a new commit does not trigger a build.

I had to implement a custom web server that acts as a proxy between Bitbucket and the CI server (e.g. Jenkins). I configure Bitbucket to send webhooks to my proxy server instead of Jenkins. The proxy server processes the webhook and determines if the new commit is on a branch that currently has a PR open. If so, it passes on the webhook information to the CI server to trigger the build.

It's quite an annoying work around for something that ought to be an event for webhooks.

Like # people like this

I set up a webhook to Buildkite and was quite surprised that there isn't an option to trigger a build when pushes are made to an existing PR. Surely that's the default CI flow?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

477 views 5 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you