This feature is available with Azure DevOps Service and Server 2019 as well as TFS 2015 and higher.
With Azure DevOps it’s possible to block the merge of a pull request if the SonarQube Quality Gate is failed on the PR (Pull Request).
This is called a Build policy in Azure DevOps, and can be defined per target branch, ie you can select which branches can accept pull request merges only if Quality Gate is passed. These branches are called protected branches
To do that:
First Select the branch you want to protect with the passed Quality Gate build policy.
Navigate to branches, and on the branch you want to protect, click on the vertical […] icon on the right.
Select the Branch policies menu
In the Branch policies screen click on Add build policy or Edit and existing build policy
In the Edit build policy screen, select le Policy requirement Build must succeed in order to complete pull requests, and save
Once this is done, you’ll notice that any pull request to be merged on the protected branch can’t be merge if the Quality Gate on the Pull Request is Failed
- TFS / Azure DevOps branch policies
- Blocking the merge of pull requests with Bitbucket Server
- Blocking the merge of pull requests with GitHub
- Blocking the merge of merge requests with GitLab
That’s it folks !