URGENT: Not able to see such branch permission as mentioned on bitbucket support docs online
Asked by Rahul:

Hi,

I am not able to see below such options in branch permission as mentioned in

1. <https://support.atlassian.com/bitbucket-cloud/docs/use-branch-permissions/>
2. <https://community.atlassian.com/t5/Bitbucket-questions/How-to-prevent-a-merge-when-one-or-more-build-in-pipeline-failed/qaq-p/907393>

I am able to see somewhat different and due to that I am not able to have/put merge checks on specific branch for failed builds. I am able to see only the below options under branch permission.

Please help me out :(![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/138355iC0E771AEEA5AA108/image-size/large?v=v2&px=999 "Capture.PNG")


Answers:
author: Rahul
body: [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579)

I am really helpless, kindly me out.


author: Mikael Sandberg
body: Hi [@Rahul](/t5/user/viewprofilepage/user-id/4346178),

Welcome to Atlassian Community!

The documentation you are linking to only applies to Bitbucket Cloud, and based on your screenshot it looks like you are on Bitbucket Server/Data Center. Here is the link to branch permissions on Server/DC, <https://confluence.atlassian.com/bitbucketserver/using-branch-permissions-776639807.html>

comments: author: Rahul
body: Hi [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579) . Thanks for your quick response :) I really appreciate it. But the link you provided doesn't fulfill my requirement.

Let me explain to you the need and it would be great if you can help me out since its really urgent:

**I have a webhook in bitbucket and I am using that to trigger a Jenkins build whenever I get a Pull request in the master branch.**

**Till here it's working.**

**Now I want, if the build fails, I simply want to close that merge option in bitbucket, or simply I want that merge option to be disabled for that Pull Request i.e., the merge for the master branch will be allowed only when the build succeeds and if the build fails, merge option to master branch is disabled/closed. (only merging to the master is to be noticed)**

The links provided in the Atlassian community for this use case are for Bitbucket cloud and I am unable to get any documentation for this use case for server/DC.

please help :)


author: Mikael Sandberg
body: Okay, so you need to configure your merge checks to only allow a merge to happen if you have at least one successful build. In Jenkins you have to use the [Bitbucket build status notifier](https://plugins.jenkins.io/bitbucket-build-status-notifier/) plugin in order to control this. Once you start a build it will notify Bitbucket that a build is in progress, and once finished it will notify that the build is successful or not. You can find more information about merge checks here, [Checks for merging pull requests](https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html).


author: Rahul
body: Hi [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579) . I really appreciate your valuable time.

I have used that **Bitbucket build status plugin** and it, in fact, sends the status of the build (either success/fail) to Bitbucket but the problem is the merge checks doc you sent me ([https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html)](https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html)?) gets applied to **all** the pull requests to **all** branches.

for example, suppose if we have **5 branches** and this merge check should happen only to the **master branch,** and the **rest 4 branches** (each given to separate developers) **are free to create a Pull request and merge freely among themselves**.

So concluding it " **I want a branch-level merge check like this** <https://community.atlassian.com/t5/Bitbucket-questions/How-to-prevent-a-merge-when-one-or-more-build-in-pipeline-failed/qaq-p/907393>**". Exactly this same thing I want in my bitbucket server.**

I hope you got my use case now.

It's great to find such people like you who are nurturing the wonderful community. Cheers :)


author: Mikael Sandberg
body: Are you doing builds on the other branches too and report the build back to Bitbucket? If not then you are good. At my previous job we were doing builds on the integration branch with the merge checks enabled for 1 successful build and that all tasks had to be completed. But we had other feature branches too, but since we did not do builds on those, or if we did, it was not reported back to Bitbucket then those merge checks are ignored.


author: Rahul
body: Hi [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579)

Correct, you guessed it right. I am not doing the build on the other branches and report the build back to Bitbucket.

Its just the master branch when getting a Pull Request triggers a build to the Jenkins job via a webhook and Jenkins sends back the build status. (Its working till here)

Now, I just want a check on**the Master branch only** that if the build is successful, allow merging (merge button enabled) and if the build fails(that Pull Request would not be allowed to merge).

Now I have an option for **minimum successful build** (you can refer to the screenshot below)- but this option is useless as**this option is at repository level and nothing is related to branch in this. I want this for the branch level.**

**That means apart from merging into the master branch, feature branches also require to pass the builds but even though there is no Jenkins job triggered for them as Bitbucket requires one successful build to merge and simply the PR merging is not allowed as this option requires a minimum of 1 build to merge- so this option is useless for me**.

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/138562i6CF4582406B9C646/image-size/large?v=v2&px=999 "Capture.PNG")

**So I want this above option (screenshot one) to be assigned just to the master branch and not to the entire repository level.**

So concluding it " **I want a branch-level merge check like this** <https://community.atlassian.com/t5/Bitbucket-questions/How-to-prevent-a-merge-when-one-or-more-build-in-pipeline-failed/qaq-p/907393>**". Exactly this same thing I want in my bitbucket server.**

Kindly see my request as I have been stuck here for many days and I am unable to find any documentation for this. Do I need to buy some plugins for Bitbucket or it is just possible in Bitbucket cloud and not in the Bitbucket server/DC?


author: Mikael Sandberg
body: No, you are getting the merge checks wrong. Take the minimum successful builds for example, this is based on a setting on the pull request. This setting can have inProgress, successful or failed. But if a commit that is part of the pull request do not have this value set the merge check is ignored. Same thing applies to the completed task check. If your pull request do not have any tasks, this check is also ignored. The only merge check that is never ignored is the number of approvers needed.


author: Rahul
body: Hi [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579) can you please tell me the steps in order to achieve my use case. I am not able to get your point.

I want to put a merge check according to Jenkins build(success/failure) on master branch(branch level) and not on repository level in bitbucket server.

Because the option which I can see is for repo level.


author: Mikael Sandberg
body: So in the repository enable the merge check for successful builds, that will cover your use case. The merge check will only be in play on your master branch and will be ignored on your other branches.


author: Rahul
body: [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579)

No Mikael,**It is not ignoring rest of the branches.**That's the problem.

**It requires successful build for merging rest branches too (other than master branch also).** **Because in "merge check for successful builds" doesn't takes any branch name as input parameter and it gets applied to all the branches implicitly.** ![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/138652i3EA2FA9ACB5D896A/image-size/large?v=v2&px=999 "Capture.PNG")

**Now see in the below screenshot I am merging two branches(** one branch name is**rahul** and other branch name i**s kumar) and master branch is not involved even though Bitbucket needs a successful build and merge check is applied to them as well but I want merge check just for master branch on the basis of Jenkins build.**

**![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/138653i2041C5FF6D869712/image-size/large?v=v2&px=999 "Capture.PNG")**

If possible can you please join **<https://fico.zoom.us/my/rahul>** . It will hardly take 5-10 minutes, its a request please :)


author: Mikael Sandberg
body: Looks like the definition has changed for the merge check then. But I found this free [app](https://marketplace.atlassian.com/apps/1218706/shadow-merge-commit-build-status?hosting=server&tab=overview) that works around that by adding a merge veto option if the build fails for a specific branch.


author: Rahul
body: No [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579) . it does not solve my use case. This is different from what my use case is.

It says "Allows to monitor the build staus of code which would be in target branch after real Pull-Request merge and veto the merge if build is failed". It's when after the PR is merged.

Don't we have any sort of Bitbucket's functionality which can fulfill my need?

Is this not possible in Bitbucket?


author: Mikael Sandberg
body: So why would the app not solve your issue? You want to make sure that what you are about to merge doesn't break anything on your main branch correct? And by default Bitbucket would not allow you to merge anything unless the source branch is up to date with the target branch. So when you do the build in Jenkins you are actually doing a build on what would be the code on the target branch. Are you doing a pre-build on the source branch even before creating a pull request to merge to main?


Tags: bitbucket-server

branch

jenkins