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.
To associate a custom quality gate with projects, see Associating projects with a quality gate.
Creating a custom quality gate
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.
From scratch
- In the top navigation bar, select Quality Gates.
- In the left panel, select the Create button. The Create Quality Gate dialog opens.
- In the dialog, enter the name of the new quality gate and select Create.
- You can now update, add or remove the conditions of the new quality gate. See Managing a custom quality gate's conditions below.
By duplication
- In the top navigation bar, select Quality Gates.
- In the left panel, select the quality gate you want to duplicate.
- In the top right corner of the quality gate, select the Actions button and then Copy. The Copy Quality Gate dialog opens.
- In the dialog, enter the name of the new quality gate and select Copy.
- You can now update, add or remove the conditions of the new quality gate. See Managing a custom quality gate's conditions below.
Managing a custom quality gate's conditions
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.
To update a condition:
- 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. - Enter the new condition's value and select Update Condition.
To add a new condition:
- Below the Conditions section, select the Unlock editing button.
- Select Add Condition. The Add Condition dialog opens.
- In Where? select to which code, new or overall, the condition applies. New code is defined through the New Code Definition.
- In Quality Gate fails when, select the metric to which the condition applies. For information about the metrics, see Understanding measures and metrics.
- In Value, enter the condition's value.
To remove a condition:
- 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. - Select Delete.
Upgrading a quality gate for CaYC
We recommend configuring all your quality gates to make them Clean as You Code (CaYC) ready. For more information, see Quality gate configured for Clean as You Code in Introduction to quality gates.
If your quality gate is not configured for CaYC, you can easily upgrade it as follows:
- In the top navigation bar, select Quality Gates.
- In the left panel, select the custom quality gate you want to upgrade.
- In This quality gate does not comply with Clean as You Code, select Review and Update Quality Gate. The Update to comply with Clean as You Code dialog opens.
- Review the proposed update and select Update Quality Gate to execute the update.
Renaming a custom quality gate
- In the top navigation bar, select Quality Gates.
- In the left panel, select the custom quality gate you want to rename.
- In the top right corner of your quality gate, select the Actions button and then Rename. The Rename Quality Gate dialog opens.
- Enter the new name and select Rename.
Deleting a custom quality gate
- In the top navigation bar, select Quality Gates.
- In the left panel, select the custom quality gate you want to delete.
- In the top right corner of your quality gate, select the Actions button and then Delete.
- Confirm the deletion.
Updating quality gates on instance mode change
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 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.
We recommend you update the metrics of your quality gate conditions to ensure accurate categorization and ranking of your issues in a given mode.
Allowing a user or group to manage a custom quality gate
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:
- In the top navigation bar, select Quality Gates.
- In the left panel, select the custom quality gate.
- 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.
- Select the user or group you want to grant.
- Select Add. The user or group is added to the Permissions section.
To remove it, select the dustbin icon.
Was this page helpful?