How to block the merge of Pull Requests when SonarQube Quality Gate is failed, with Azure DevOps Services

The Azure Devops cloud offering recently improved with tighter integration of PR Analysis Quality Gate status checks.
The guide for the configuration for Azure Devops Server 2019 and TFS 2015+ is still applicable.

This post thus describes the configuration steps needed to block the possibility to merge PRs after the Quality Gate for them failed:

Prerequisites:

To do that:

  1. Select the branch you want to protect by enforcing the Quality Gate check. Navigate to branches, on the branch you want to protect, click on the vertical […] icon on the right, and select the Branch Policies menu:

  2. In the Branch Policies screen, add a Status Check:

  3. Search and select SonarQube/quality gate, set it as Required and save:

You are all set!

2 Likes