Is there a way to prevent merging of one branch to another. We have branches like 15-maint 16-maint master, we merge forward from 15-maint to 16-maint and also from 16-maint to master but never from 16-maint to 15-maint or from master to 16-maint. Sometimes due to human error, of the person merging, higher branch is merged to lower - like 16-maint to 15-maint or master to 16-maint. Is there any way to prevent this by means of hooks or configs in Bitbucket ?
Hi Bopanna
You can use branch level permissions and a branch naming convention to limit who has the capability to merge. Take a look at the documentation available at https://confluence.atlassian.com/display/BitbucketServer/Using+branch+permissions
Cheers
Bhushan
@b bopanna would you please elaborate why branch permissions won't work for you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ulrich Kuhnhardt [Izymes]: There are 4 restrictions available :
i. Prevent all changes
ii. Prevent deletion
iii. Prevent rewriting history
iv. Prevent changes without a pull request
Now how can I use these to configure my lower branches to not allow merges from higher ? (do not permit merge of master to 16-maint while allowing merging of 15-maint to 16-maint ?)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm looking for the solution similar to the issue posted here. How can I restrict committers from merging `any branch` -> `master` except `develop` branch.
Use cases:
* prevent from merging feature/bugfix/.. branches to master
* except develop to master
Can anyone help to achieve this using bitbucket.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bhushan Nagaraj as others have commented, this does not answer/fulfill the the OP's question. There's a valid use case to set branch merge checks such as: "Only let qa branch merge into prod branch". Or "Only let branch pattern x merge into target y branch."
This should be a setting/feature of Bitbucket. You can't accomplish this easily or cleanly with user/group/access key permissions on branches. Arguing that you use a set of required reviewers for this check is hacky and introduces human error and bottle necks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@TVeal definitely not trying to argue, only trying to help :)
The natively supported features for branch permissions and merging is documented in the link I have provided previously.
For more complex use cases and scenarios, you can write a custom hook at the various trigger points available. This is documented at https://developer.atlassian.com/server/bitbucket/how-tos/hooks-merge-checks-guide/
For the examples you have provided, you could use the PULL_REQUEST_MERGE trigger.
Hope that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello All!
Just to offer a suggestion of what we have done in this same scenario. We have a small group (in our case 3) Git experts who are added as default reviewers and only they are capable of merging into the master branch or the 16-maint equivilant.
We are using the Prevent all changes with an exception to the single group that has our git experts on it so they are notified when changes come in for that branch and they are the only ones who can merge to it to ensure we don't have accidents.
Now, it's true these are still humans who can make mistakes but since it is a smaller group who are on the same team and they are experts we have significantly fewer issues doing it this way.
Just another thought.
-James
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.