Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Branch Restrictions

Elena Dzhordzhilova March 5, 2024

Dear Bitbucket Community,

 

I would want to ask if you have any information about branch restriction where I need 2 approvals for PRs:

- 1 of the approvals must be from "default reviewers"

- 1 of the approvals can be from anyone who can access the repository.

and if there are two approvals, anyone who has access to the repository, to be able to merge or if there aren't enough approvals, only the default reviewers to be able to merge.

The configs which I tried were:

- From: Repository Settings -> Branch restrictions -> Actions (on the desired branch) -> Edit -> Merge Settings -> Minimum number of approvals (2) and Minimum number of approvals from default reviewers (1) , because if one approval is set from default reviewers it will be also counted in "Minimum number of approvals". Also set "Prevent a merge with unresolved merge checks" to prevent merges if the approvals are not enough, but everyone will be able to merge, but in this case, the default reviewers cannot merge without all approvals too. If I set restriction in "Branch Permissions" inside the list "Merge access via pull request", then only the whitelisted users will be able to merge which is not what I need and if  "Prevent a merge with unresolved merge checks" is enabled, it will also avoid merge, even if the users are with "Admin" permissions for the repository.

 

Best Regards,

Elena

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 6, 2024

Hi Elena,

The closest thing to what you are asking is the following:

  • Set Minimum number of approvals (2) and Minimum number of approvals from default reviewers (1)
  • Set "Prevent a merge with unresolved merge checks"
  • Give write access to the destination branch (from the branch restriction, option Only specific people or groups have write access) to the users you have as default reviewers

The default reviewers will not be able to merge the PR that doesn't have the necessary number of approvals.

However, they will be able to:

  1. Go to the Branches page of the repo
  2. Select the source branch of the PR on this page
  3. On the new page that opens there is an option to Compare with a certain branch. They can choose to compare with the destination branch of the PR
  4. Afterwards, they can select the 3 dots (on the left of the Settings button) > Merge

If they merge the branches this way with merge strategy Fast forward or Merge commit, then the PR is also going to be marked as merged automatically.

Please keep in mind that if you give the default reviewers write access to the destination branch via the Branch permission, they will be able to merge the branches even when there are zero approvals in the PR and also push to the branch.

Please feel free to reach out if you have any questions!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events