Hello, Atlassian community!
I'm trying to add a successful build restriction for merging pull request. If I get it right, the idea is when one presses merge button (which is clickable after reviewers have approved it) that action triggers, for example, jenkins job and if it is successful, performs the merge, otherwise tells you it wasn't performed due to build failure.
My current setup (integration) with jenkins involves web-hooks to triggers jobs, I'm aware about event payloads and stuff, but cant find anything related to the example I provided above - does it work on the same principle? where do I specify what job to trigger? For example, I couldnt find any relevant event for that over here - https://confluence.atlassian.com/bitbucketserver0514/using-bitbucket-server/managing-webhooks-in-bitbucket-server/event-payload?utm_campaign=in-app-help&utm_medium=in-app-help&utm_source=stash#Eventpayload-repositoryevents. Merged event looks like the one that happens on completed merge, which is not what Im looking for.
Looking for more detailed explanation/guide.
You cannot kick off a build when clicking the merge button and use the built-in check that only allows merging a pull request if there are minimum successful builds, that check happens before the merge button is enabled. The way I have it set up in my Bitbucket environment is to use a free app called Pull request notifier for Bitbucket. It used to be listed on the Marketplace, but the developer pulled it after Bitbucket 6.0 release but has now updated the app so it works with Bitbucket 6.x. The app sends a webhook to Jenkins based on your configuration, and then on Jenkins we use Bitbucket Notifier Plugin to let Bitbucket know of the build result.
You may also want to take a look at the Atlassian supported Jenkins integration that was just released. It does not allow you to control when the webhook is triggered, but if you want to build on every commit, I would use this one.
Thank you, @Mikael Sandberg, for your reply. I think I'll consider builds on every commit, through webhooks though, as I realized our company jenkins environment doesn't have bitbucket plugin that you mentioned. And you know it may take time to be added...
I want to ask you one more question - I've seen there is an event, called "Approved", which is triggered when one of the reviewers approves the pull request. I think I could use this one to reduce the number of unncessary builds. Of course I'm going to test it, just interested in your thoughts.
Thanks again for quick reply!
Also found something called "External Merge Check Hook" in Pull requests -> Merge checks section. I realized its an Add-on, but since I'm not Bitbacket admin in our environment, I happen to find things on the way xD
More info - https://external-hooks.reconquest.io/
Do you have any experience using this one?
Hey, I'm one of the External Hooks add-on maintainers.
You can use External Merge Check hook to veto pull request merge using arbitrary executable (e.g. shell script).
How it works:
Feel free to reach us directly if you need more help: email@example.com
My best guess is to triggers jobs on every commit and mark them successful/failed using REST API https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/
Please confirm if that's how it is done.
Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster ! While we’re all excited about the new improvements to Bitbucket ...
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