Skip to main content

Create a quality gate with Bitbucket

David Martin avatar
Written by David Martin
Updated yesterday

What is a Quality Gate?

A quality gate is the best way to enforce a quality policy in your organization. Setting up a quality gate allows you to prevent any code that doesn't pass code reviews from being merged into certain branches.

Key Benefits

  • Enforce code quality consistency across the entire project.

  • Ensure that newly committed code doesn't introduce problems.

  • Ensure issues are addressed before being merged.

Before to start

Before proceeding with creating a quality gate in your VCS for your repo, you must enable the Clayton Automation for your project.

Enable Automation

To automatically monitor your code with Clayton, you need to turn on and select a protection mode. Clayton automatically creates webhooks to monitor relevant events in your repository. You can select your protection mode from the homepage by navigating to Settings and then Protection. From there, you can view the current settings and adjust the protection mode as needed.


Connection User

Bitbucket mandates that Pull Requests (PRs) receive approvals from a user distinct from the original author. To ensure the quality gate operates fully with Clayton, it is crucial to set up a dedicated connection user for Clayton within your project.
​

Setting up brach protection

  1. In your repository settings in Bitbucket, go under Settings > Branch permissions.

  2. Install our official Bitbucket app.

  3. Go to Bitbucket > Repository > Repository settings > Branch restrictions.

  4. Select the branch you would like to create the gate for.

  5. Click on Edit > Merge checks.


Suggested Setup


Suggested Setup

To optimize your quality gate, we recommend the following configurations:

  • Define Required Approvals: Set the number of approvals needed for a merge. For instance, you might require approval from 2 developers and 1 architect.

  • Align Builds with Policies: Configure the minimum number of successful builds to match the number of active Clayton policies in your project. For example, if you have 6 active Clayton policies, set the requirement for 6 successful builds.

  • Ensure Validation on New Development: Enable the "Reset requested changes when the source branch is modified" flag. This ensures that any new changes pushed to the source branch are re-validated by the quality gate.

  • Prevent Bypassing Checks: Select the "Prevent a merge with unresolved merge checks" flag. This critical setting ensures that no changes can bypass the defined quality checks and effectively enforces your development standards.

  • Save Your Settings: After configuring these options, click "Save" to apply your changes.

Read more


​

Did this answer your question?