Skip to main content

Create a quality gate with GitLab

How to set up quality gates in Gitlab to work with Clayton

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 merge

Before you start

Before proceed with creating a quality gate in your VCS for your repo, you must enable Clayton Automation and create a dedicated Clayton connection user for your project. It's also important to note that to use this feature in Gitlab you will need to be on the Premium plan.

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.
​
You can find out more information about the process on this Help Article


Configure Clayton as a required approval for your merge requests

Go to GitLab, navigate to your repository's General settings, and expand the Merge request approvals section.

Select Add approval rule or Update approval rule (this feature requires a Premium or Ultimate version of GitLab).
​

Add the Clayton connection user to the approvers and ensure the Approvals required field is set to at least 1.
​


Click on Save changes

Status checks

To enable Status Checks in GitLab or Gearset, make sure the "Pipelines must succeed" setting is activated. This setting covers Gearset validation-only jobs as well as each Clayton policy, ensuring that pipelines are successfully completed before merging. Additionally, the "Threads must be resolved" option ensures that any Clayton report, stamped as a comment, along with any other reviewer comments, are addressed before merging. You can find both options within your repository's settings under Merge Requests, specifically in the Merge Checks section.

Did this answer your question?