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.
Hi @[deleted],
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you use the minimum successful build check then triggering the build on the Approved event should be fine if you want to avoid a lot of extra builds. In that case, I would also enable Auto-unapprove if you have not done that already.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted]
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: we@reconquest.io
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.