# Blocking the merge of Pull Requests on failed Quality Gate, with Azure DevOps Services

**URL:** <https://community.sonarsource.com/t/blocking-the-merge-of-pull-requests-on-failed-quality-gate-with-azure-devops-services/26901>\
**Category:** Guides\
**Tags:** azuredevops-services, pull-request, sonarqube\
**Created:** [June 23, 2020, 9:50am UTC](https://community.sonarsource.com/t/blocking-the-merge-of-pull-requests-on-failed-quality-gate-with-azure-devops-services/26901 "2020-06-23T09:50:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylvain\_Combe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sylvain_combe/32/3972_2.png) [@Sylvain\_Combe](https://community.sonarsource.com/u/Sylvain_Combe)\
**Post date:** [June 23, 2020, 9:50am UTC](https://community.sonarsource.com/t/blocking-the-merge-of-pull-requests-on-failed-quality-gate-with-azure-devops-services/26901/1 "2020-06-23T09:50:20Z")

</div>

The Azure Devops cloud offering as well as recent versions of Azure Devops Server were improved with tighter integration of PR Analysis Quality Gate status checks.  
The [guide for the configuration for Azure Devops Server 2019 and TFS 2015+](https://community.sonarsource.com/t/how-to-block-the-merge-of-pull-requests-when-sonarqube-quality-gate-is-failed-with-azure-devops/19499) 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:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/1/1e83b7e51dc3b72d36b2daaa48700733b79dfa04.png)

Prerequisites:

- SonarQube 8.x (official Azure Devops Services support expected for the next LTS with [MMF-2132](https://jira.sonarsource.com/browse/MMF-2132))
- [SonarScanner for Azure Devops](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/) installed
- Project analyzed with SonarQube with PR decoration enabled as documented with [Reporting your Quality Gate status in Azure DevOps](https://docs.sonarqube.org/latest/analysis/azuredevops-integration/#header-4/)
- Project build pipeline set with the **Publish Quality Gate Result** task

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!**

Quick tips:

- a pipeline is triggered on your PRs when Build Validation is set for the branch. Make sure you select it as well.
- the Quality Gate status may show on Azure UI only after a first PR has been analyzed.

---

<div class="post-metadata">

**Author:** ![Sylvain\_Combe](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sylvain_combe/32/3972_2.png) [@Sylvain\_Combe](https://community.sonarsource.com/u/Sylvain_Combe)\
**Post date:** [November 3, 2020, 1:18pm UTC](https://community.sonarsource.com/t/blocking-the-merge-of-pull-requests-on-failed-quality-gate-with-azure-devops-services/26901/4 "2020-11-03T13:18:03Z")

</div>

Closed on November 3, 2020, 1:18pm UTC


