Issue: I have a web hook for firing off a build when a pull request is merged. my issue is that the web hook is firing the build when the Pull request is created. this is causing the build to fail since the branch that is being build is from the previous build. I'm not sure why it is firing the hook when the PR is created. I only have "Pull request merged" checked.
Welcome to the Atlassian Community!
How are you confirming that the webhook is firing on the PR being created? If you are only checking to see if the build starts, is it possible that your CI is checking for PRs on top of the Webhook? More importantly, when you do merge the PR, does the webhook fire as expected? A quick test would be to just disable the webhook and open a PR to see if a build starts (and fails). Off-hand, I'm not sure exactly what else it could be. I assume you are using the webhooks built-in to Bitbucket?
Dev Tools Support Engineer
The web hook we created is pretty strait forward. My CI is not checking for anything. my web hook call a URL on jenkins which fires off a build. the issue is that if the build is triggered when the PR is created, the same build will fail when it is merged since the version is the same
Could we get some confirmation on some of the questions I asked previously?
Also if you are able to upload any screenshots of how things are configured on both the Bitbucket and Jenkins side, that would be appreciated. I wasn't able to reproduce this behavior. I am using the latest version of Bitbucket Server of 5.11.1 and the latest version of Jenkins with 2.121.1. What version of Bitbucket are you using (or are you using cloud) and what version of Jenkins are you working with?
Below is answer for your query
Is this Webhook being created from the Bitbucket Webhook tab in the repository settings? Yes - I am using Post Webhook under repository settings
If you disable the webhook, can you confirm the behavior of Bitbucket with Jenkins (or what we should expect to be no behavior at all)? - Yes it is working fine
You said "the build will fail when it is merged" does that mean you attempted to do so or is this speculation (as in you confirmed that the hook is sent on merge as well as created)? Yes it is sending for both the event but we want built should be trigger only when merge happen to latest releas branch.
If you are doing the Post Webhooks then that isn't the default Webhooks that is bundled with Bitbucket. That is a third part Post Webhooks plugin. But I wasn't able to reproduce the issue with that plugin either. If you go the Webhooks section instead of Post Webhooks and try to create one there do you see the same issue? Could you also confirm what version of Bitbucket you are using?
Hello Community, I’m Anton Genkin, a product manager on the Bitbucket Server and Data Center team and am excited to share that Bitbucket Server 7.0 is now available! It's a platform release, one th...
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