How can i block the user to merge pull-request on Bitbucket if the jenkins build gets failed

Viewed 3887

A jenkins build is triggered when a user creates a pull request on Bitbucket. The user waits for the result of this build. When the build is completed, the result of this build is notified back to Bitbucket server through bitbucket server notifier plugin. Now, if the build is successful, the user should be able to merge otherwise the merge should be blocked (or the merge button should be disabled). In other words, whenever the pull request is created the merge button should remain disabled unless the build is successful.

How can i achieve this ? Thanks

1 Answers

In BitBucket they have a feature called merge checks.

you can check for following conditions:

Check for at least {#} approvals
Check for unresolved pull request tasks
Check for {#} passed builds on the last commit

However, on the free plan it'll just be a warning.

When you select any of these options (and don't have the Premium plan), we'll warn users when they have unresolved merge checks, but they'll still be able to merge. To prevent users from merging, upgrade to Premium and select Prevent a merge with unresolved merge checks.

So you'll need a premium plan to stop users from merging if build fails. You can read more about it in their docs: https://support.atlassian.com/bitbucket-cloud/docs/suggest-or-require-checks-before-a-merge/

Related