# Managing custom quality gates

*This feature is only available in the Team and Enterprise plans. See* [subscription-plans](https://docs.sonarsource.com/sonarqube-cloud/administering-sonarcloud/managing-subscription/subscription-plans "mention") *for more information.*

Two built-in quality gates are provided in your organization but you can create your own quality gates, called custom quality gates. To manage custom quality gates, you need the Administer Quality Gates permission. With this permission, you can also associate projects to quality gates in your organization.

For more information about quality gates, read the [introduction-to-quality-gates](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-gates/introduction-to-quality-gates "mention") page.

To associate a custom quality gate with projects, check out the [associating-projects-with-quality-gate](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-gates/associating-projects-with-quality-gate "mention") page.

## Creating a custom quality gate <a href="#creating-a-custom-quality-gate" id="creating-a-custom-quality-gate"></a>

You can create a custom quality gate from scratch or by duplication. When you create a custom quality gate from scratch, the conditions of the built-in quality gate **Sonar way** are automatically copied to the new record to make your custom quality gate ready for Clean as You Code.

<details>

<summary>From scratch</summary>

1. Retrieve your organization. See [viewing-organizations](https://docs.sonarsource.com/sonarqube-cloud/getting-started/viewing-organizations "mention") for details.
2. Go to **Quality Gates**.
3. In the left panel, select the **Create** button. The **Create Quality Gate** dialog opens.
4. In the dialog, enter the name of the new quality gate and select **Create**.
5. You can now update, add or remove the conditions of the new quality gate. See **Managing a custom quality gate’s conditions** below.

<div align="left"><figure><img src="https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2FpCKPVx918uwWtMPI5HKW%2Fquality-gates-create.png?alt=media&#x26;token=cd455f4f-b910-4247-8f6f-b74f2d87dac4" alt="Creating a quality gate from scratch"><figcaption></figcaption></figure></div>

</details>

<details>

<summary>By duplication</summary>

1. Retrieve your organization. See [viewing-organizations](https://docs.sonarsource.com/sonarqube-cloud/getting-started/viewing-organizations "mention") for details.
2. Go to **Quality Gates**.
3. In the left panel, select the quality gate you want to duplicate.
4. In the top right corner of the quality gate, select the More Actions button and then **Copy**. The **Copy Quality Gate** dialog opens.
5. In the dialog, enter the name of the new quality gate and select **Copy**.
6. You can now update, add or remove the conditions of the new quality gate. See **Managing a custom quality gate’s conditions** below.

<figure><img src="https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2F8L4qKjnens4Ey3qFXsKn%2Fquality-gates-copy.png?alt=media&#x26;token=61ddd695-36ba-4f73-8f48-f7bd715af472" alt="Copying an existing quality gate"><figcaption></figcaption></figure>

</details>

## Managing a custom quality gate’s conditions <a href="#managing-conditions" id="managing-conditions"></a>

You can add or remove conditions. You can update the value of an existing condition. Remember that you define failing conditions: if one of the conditions is met, the quality gate fails. For more information about conditions, see the article about [#definition-based-on-conditions](https://docs.sonarsource.com/sonarqube-cloud/standards/introduction-to-quality-gates#definition-based-on-conditions "mention").

**To update a condition:**

1. Select the edit icon in the far right of the condition row. If there is no edit icon, select first the **Unlock editing** button, below the **Conditions** section.\
   The **Update Condition** dialog opens.
2. Enter the new condition’s value and select **Update Condition**.

**To add a new condition:**

1. Select **Add Condition**. The **Add Condition** dialog opens.
2. In **Where?** select to which code, new or overall, the condition applies. New code is defined through the New Code Defintion (NCD). See the[about-new-code](https://docs.sonarsource.com/sonarqube-cloud/standards/about-new-code "mention") page for more information.
3. In **Quality Gate fails when**, select the metric to which the condition applies. For information about the metrics, see the [metric-definitions](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/metric-definitions "mention") page.
4. In **Value**, enter the condition’s value.

{% hint style="info" %}
Quality gate conditions related to severity currently use type severities. For more details, see the list of Issue management solution metrics in the [#issues](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/metric-definitions#issues "mention") table.
{% endhint %}

**To remove a condition:**

1. Select the dustbin icon in the far right of the condition row. The **Delete Condition** dialog opens.
2. Select **Delete**.

## Updating a quality gate <a href="#upgrading-to-clean-as-you-code" id="upgrading-to-clean-as-you-code"></a>

We recommend configuring all your quality gates to prevent issues in new code. For more information, see the [#quality-gate-and-new-code](https://docs.sonarsource.com/sonarqube-cloud/standards/introduction-to-quality-gates#quality-gate-and-new-code "mention") article.

If your quality gate is not configured according to standards recommended by Sonar, you can easily update it as follows:

1. Retrieve your organization. See [viewing-organizations](https://docs.sonarsource.com/sonarqube-cloud/getting-started/viewing-organizations "mention") for details.
2. Go to **Quality Gates**.
3. In the left panel, select the custom quality gate you want to upgrade.
4. In **Consider updating conditions for new code** callout, select **Review and Update**. The **Update Conditions on new code** dialog opens.
5. Review the proposed update and select **Update Quality Gate** to execute the update.

## Renaming a custom quality gate <a href="#renaming-quality-gate" id="renaming-quality-gate"></a>

1. Retrieve your organization. See [viewing-organizations](https://docs.sonarsource.com/sonarqube-cloud/getting-started/viewing-organizations "mention") for details.
2. Go to **Quality Gates**.
3. In the left panel, select the custom quality gate you want to rename.
4. In the top right corner of your quality gate, select the More Actions button and then **Rename**. The **Rename Quality Gate** dialog opens.
5. Enter the new name and select **Rename**.

## Deleting a custom quality gate <a href="#deleting-quality-gate" id="deleting-quality-gate"></a>

1. Retrieve your organization. See [viewing-organizations](https://docs.sonarsource.com/sonarqube-cloud/getting-started/viewing-organizations "mention") for details.
2. Go to **Quality Gates**.
3. In the left panel, select the custom quality gate you want to delete.
4. In the top right corner of your quality gate, select the More Actions button and then **Delete**.
5. Confirm the deletion.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [introduction-to-quality-gates](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-gates/introduction-to-quality-gates "mention")
* [viewing-quality-gate](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-gates/viewing-quality-gate "mention")
* [changing-default-quality-gate](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-gates/changing-default-quality-gate "mention")
* [associating-projects-with-quality-gate](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-quality-gates/associating-projects-with-quality-gate "mention")
* [notifications](https://docs.sonarsource.com/sonarqube-cloud/managing-your-account/notifications "mention")
* [quality-gates-for-ai-code](https://docs.sonarsource.com/sonarqube-cloud/standards/ai-code-assurance/quality-gates-for-ai-code "mention")
* [changing-quality-gate](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/project-analysis/changing-quality-gate "mention")

## Related online learning

* <i class="fa-video">:video:</i> [Administering quality gates in SonarQube](https://www.sonarsource.com/learn/course/core-concepts/a0f784bb-0722-4c97-ac5f-9e250686014b/administering-quality-gates-in-sonarqube)
