Gitflow workflow states that Hotfix branches will be merged to both Develop and Master branches. Since engineers forgot more than once to merge their hotfix to Develop, I want to mandate that the merge to develop is done first. How can I configure Bitbucket to block merges of commits, that do not already exist in Develop, to master?
Asked
Active
Viewed 318 times
0
-
Your tags are a bit confusing here - is this for Bitbucket Cloud (bitbucket.org) or Bitbucket Server (self-hosted)? – Jim Redmond Jun 04 '18 at 19:20
-
@JimRedmond, It's Bitbucket Server (self-hosted). – Maor Jun 07 '18 at 09:30
-
Got it. You should remove the "bitbucket-pipelines" tag, then. – Jim Redmond Jun 07 '18 at 17:58
1 Answers
1
I don't know about BitBucket, but if you're able to install your own hooks, it's easy enough to script whatever you want in a pre-recive or update hook.
The following is an (untested) example, there are perhaps more efficient git commands to accomplish this, I'm not sure.
#!/bin/bash
# ... << Code to set up your hook variables here >>> ...
if [ "$(git branch Develop --contains $new_rev | wc -l)" -eq 0 ]; then
echo "ERROR: You must commit to Develop first and then merge"
exit 1
fi
exit 0

Mort
- 3,379
- 1
- 25
- 40
-
1You can indeed install your own server-side hooks in Bitbucket Server. It's not encouraged, since it's somewhat opaque (easy to install hooks, forget about them, then have users or future admins going down a troubleshooting rabbit hole for days or weeks). Read [How to create a simple hook in Bitbucket Server](https://confluence.atlassian.com/bitbucketserverkb/how-to-create-a-simple-hook-in-bitbucket-server-779171711.html) (skip past the stuff about Java hooks, it describes basic script hooks further down). – daveruinseverything Jun 10 '18 at 01:50