# Managing custom quality gates

Two built-in quality gates are provided 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 and allow another user to administer a given custom quality gate.

For more information on quality gates, see [introduction-to-quality-gates](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/introduction-to-quality-gates "mention").

To associate a custom quality gate with projects, see [associating-projects-with-quality-gate](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/associating-projects-with-quality-gate "mention").

## 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 quality gate.

<details>

<summary>From scratch</summary>

1. In the top navigation bar, select **Quality Gates**.
2. In the left panel, select the **Create** button. The **Create Quality Gate** dialog opens.
3. In the dialog, enter the name of the new quality gate and select **Create**.
4. You can now update, add or remove the conditions of the new quality gate. See **Managing a custom quality gate’s conditions** below.

</details>

<details>

<summary>By duplication</summary>

1. In the top navigation bar, select **Quality Gates**.
2. In the left panel, select the quality gate you want to duplicate.
3. In the top right corner of the quality gate, select the Actions button and then **Copy**. The **Copy Quality Gate** dialog opens.
4. In the dialog, enter the name of the new quality gate and select **Copy**.
5. You can now update, add or remove the conditions of the new quality gate. See **Managing a custom quality gate’s conditions** below.

</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 **Quality gate definition based on conditions** in [introduction-to-quality-gates](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/introduction-to-quality-gates "mention").

**To update a condition:**

1. Select the pen icon in the far right of the condition row. If there is no pen 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. Below the **Conditions** section, select the **Unlock editing** button.
2. Select **Add Condition**. The **Add Condition** dialog opens.
3. In **Where?** select to which code, new or overall, the condition applies. New code is defined through the New Code Definition (NCD). More information about the NCD can be found on the [about-new-code](https://docs.sonarsource.com/sonarqube-community-build/user-guide/about-new-code "mention") page.
4. In **Quality Gate fails when**, select the metric to which the condition applies. For information about the metrics, see the [metrics-definition](https://docs.sonarsource.com/sonarqube-community-build/user-guide/code-metrics/metrics-definition "mention") page.
5. In **Value**, enter the condition’s value.

**To remove a condition:**

1. Select the dustbin icon in the far right of the condition row. If there is no dustbin icon, select first the **Unlock editing** button, below the **Conditions** section.\
   The **Delete Condition** dialog opens.
2. Select **Delete**.

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

For more information, see the [#quality-gate-and-new-code](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/introduction-to-quality-gates#quality-gate-and-new-code "mention") article.

If your quality gate is not configured to use the [standards recommended by Sonar](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/introduction-to-quality-gates#quality-gate-and-new-code), you can easily upgrade it as follows:

1. In the top navigation bar, select **Quality Gates**.
2. In the left panel, select the custom quality gate you want to upgrade.
3. In **Consider updating conditions on new code**, select **Review and Update Quality Gate**. The **Update conditions on new code** dialog opens.
4. 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. In the top navigation bar, select **Quality Gates**.
2. In the left panel, select the custom quality gate you want to rename.
3. In the top right corner of your quality gate, select the Actions button and then **Rename**. The **Rename Quality Gate** dialog opens.
4. Enter the new name and select **Rename**.

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

1. In the top navigation bar, select **Quality Gates**.
2. In the left panel, select the custom quality gate you want to delete.
3. In the top right corner of your quality gate, select the Actions button and then **Delete**.
4. Confirm the deletion.

## Updating quality gates on instance mode change <a href="#instance-mode-change" id="instance-mode-change"></a>

With the SonarQube Community Build instance admin permissions, you can change the instance’s mode from Standard Experience to MQR Mode and vice versa. After you change the mode, you may have to update some quality gates, as the modes use different metrics and affect software qualities in different ways. See the [changing-modes](https://docs.sonarsource.com/sonarqube-community-build/user-guide/code-metrics/changing-modes "mention") page for details.

You do not have to update **Sonar way** quality gates as they are updated automatically for each mode.

When an update to a custom quality gate is available, you will see an update icon on the list of your custom quality gates.

To update your quality gate:

* Select a quality gate that displays the update icon from the list of quality gates.
* Click on each condition that displays the update icon and go through the update process. You cannot edit conditions until they are updated.

The conditions’ metrics will be calculated differently even if the conditions’ names persist between the modes. **Operator** and **value** will remain unchanged.

{% hint style="info" %}
We recommend you update the metrics of your quality gate conditions to ensure accurate categorization and ranking of your issues in a given mode.
{% endhint %}

## Allowing a user or group to manage a custom quality gate <a href="#allowing-user-to-manage-custom-quality-gate" id="allowing-user-to-manage-custom-quality-gate"></a>

You can grant a user or group the Administer Quality Gates permission for an existing custom quality gate. You can remove the permission any time.

Proceed as follows:

1. In the top navigation bar, select **Quality Gates**.
2. In the left panel, select the custom quality gate.
3. In the **Permissions** section, at the bottom of the quality gate page, select **Grant permissions to a user or group**. The **Grant permissions** dialog opens.
4. Select the user or group you want to grant.
5. Select **Add**. The user or group is added to the **Permissions** section.\
   To remove it, select the dustbin icon.

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

* [introduction-to-quality-gates](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/introduction-to-quality-gates "mention")
* [viewing-quality-gate](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/viewing-quality-gate "mention")
* [changing-default-quality-gate](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/changing-default-quality-gate "mention")
* [associating-projects-with-quality-gate](https://docs.sonarsource.com/sonarqube-community-build/quality-standards-administration/managing-quality-gates/associating-projects-with-quality-gate "mention")
* [subscribing-to-notifications](https://docs.sonarsource.com/sonarqube-community-build/user-guide/managing-your-account/subscribing-to-notifications "mention")
* [changing-quality-gate-and-fudge-factor](https://docs.sonarsource.com/sonarqube-community-build/project-administration/adjusting-analysis/changing-quality-gate-and-fudge-factor "mention")
