Your master branch represents the code that you will ship to your customers, and should be protected at all costs. No one intends to ship a bug to a customer on purpose, so having a mechanism in place to catch these subtle bugs is essential to a development team. Code review has been around in some form since the dawn of version control to help keep a close eye on the master branch and ensure code quality is high.

Pull requests in particular provide a way to do peer code reviews and merges as part of a branch-based development workflow. As teams grow sometimes you need to take pull requests a step further to really make sure code is ready to be merged in to the family jewel: the master branch.

Merge Checks in Bitbucket Cloud

That’s why we added merge checks to Bitbucket: they make it easy to ensure that every pull request is fully vetted before it gets merged. This gives teams the flexibility to:

  • Require a certain number of approvers: get at least 1 additional set of eyes on any change before it is merged. (On the Bitbucket Cloud team, we require 2 approvals for every Pull Request.)
  • Require a certain number of successful builds: Peer reviews are great but take that extra step and make sure the builds are passing pre-merge. Everyone says don’t break the build, but do you mean it?
  • Require all tasks to be completed: those tasks are there for a reason. Make sure all the feedback reviewers leave gets addressed, instead of promises to fix it later.
  • Reset approvals when the source branch of a pull request is modified: along with required approvers, this guarantees that no change goes unreviewed. This can be overkill for some branches, where reviewers can approve a PR while trusting the author to make some small tweaks, but it’s great for making sure nothing slips into a critical branch (typos in the release branch, anyone?).

Atlassian is a public company, so the Bitbucket team uses these checks as part of our compliance controls to prevent unauthorized changes to our code, and we know many teams have similar requirements. We also know that having an entire repository locked down can be frustrating, which is why we made merge checks totally configurable at the branch level. Production code can be protected and thoroughly reviewed but until it’s ready, you can still iterate quickly on features in dev and staging, all in the same repository.

Try Merge Checks

Merge checks are a feature in Bitbucket Cloud’s Premium plan which has features for teams that require granular admin controls, security and auditing. Bitbucket Cloud Premium is available at $5/user/month.

If you’re ready to get started, sign up for a free Bitbucket Cloud account or upgrade to Premium.

If you’re already a Bitbucket Cloud Premium user, you can add merge checks from your repository settings menu, under the branch permissions section.

Happy coding!

Get started for free

Have more specific questions about this post? Reach out to us on Twitter to get the information you need

The post Protect your master branch with Merge Checks appeared first on Bitbucket.