Start Free
Latest | DevOps platform integration | Azure DevOps integration | Setting up integration for your project

Setting up feature integration with Azure DevOps for your project

On this page

This page explains how to add SonarQube Server connection (necessary if you use Azure Pipelines) and how to set up the pull request integration with Azure DevOps for your SonarQube Server project.

Adding SonarQube Server service connection to Azure Pipelines (SonarQube Server endpoint)

Service connections are authenticated connections between Azure Pipelines and external or remote services. You must declare your SonarQube Server as a service connection in your Azure DevOps project.

Proceed as follows:

  1. In SonarQube Server, create an authentication token that will be used by Azure DevOps to execute the analysis of your project in SonarQube Server. To do so, create a Project analysis token for your project and copy it (you may also use a Global analysis token, but it’s not recommended). For more information, see Managing your Tokens.
  2. In your Azure DevOps project, go to Project Settings > Service connections.
  3. Select New service connection and then select SonarQube Server from the service connection list.
  4. Enter your SonarQube Server URL, the token created in the first step, and a memorable Service connection name (You will need this name when configuring your Azure build pipelines). Then, select Save to save your connection.

Setting up pull request integration

SonarQube Server can:

  • Report the quality gate status and analysis metrics to your pull requests in Azure DevOps. 
  • Show issues detected on a pull request in Azure DevOps. Each issue will be a comment on the Azure DevOps pull request. If you change the status of an issue in SonarQube Server, that status change is immediately reflected in the Azure DevOps interface.  

To set up the pull request analysis:

  1. See the prerequisites in Setting up the pull request analysis.
  2. Enable the pull request analysis on the target branch: see below.
  3. When running on Azure Pipelines, the SonarScanners can automatically detect the pull request parameters. If you don't use an integrated CI tool, you must set up these parameters manually: see Setting up the pull request analysis
  4. For an unbound project, an additional setup is required: see below.
  5. You can prevent the pull request merge if the quality gate fails: see below.
Enabling pull request analysis on target branch

To ensure that all of your pull requests get automatically analyzed:

Additional setup for an unbound project

For an unbound project (a project not created by importing the corresponding Azure DevOps repository), an additional setup is required as explained below:

  1. Retrieve the project in SonarQube Server and select Project Settings > General Settings > DevOps Platform Integration.
  2. Enter the Project name and Repository name.
Preventing pull request merges when the quality gate fails

To prevent the merge of pull requests when the quality gate fails, proceed as follows (you can also watch this video for a quick overview of the procedure):

  1. Go to the Branch policies page of your main branch.
  2. Under Require approval from additional services, select Add status policy.
  3. In the Status to check dropdown, select SonarQube/quality gate.
  4. Then choose the option depending on your need:
    • Optional: Users will be able to merge a pull request even if the quality gate fails. 
    • Required: Users will not be able to merge a pull request unless the quality gate passes.
  5. Select Save.

Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License