Start Free
2025.1 | DevOps platform integration | Azure DevOps integration | Setting up project integration

Setting up project integration with Azure

On this page

This page explains project-level settings required if you use Azure DevOps and / or Azure Pipelines for your project analysis.

Setting up pull request integration with Azure DevOps

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. If you don't use an integrated CI tool like Azure Pipelines, you must set up the pull request parameters manually: see the pull request parameters setup in 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.

Setting up integration with Azure Pipelines

If you use Azure Pipelines, you must configure a service connection in Azure and enable the pull request analysis in your pipeline.

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, create an authentication token that will be used by Azure DevOps to execute the analysis of your project in SonarQube. To do so, create a token and copy it. 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.

Enabling the pull request analysis in your build pipeline

The Azure DevOps extension running in your Azure pipeline can automatically detect branches or pull requests being built (you don't need to pass them as parameters to the scanner). 

To enable the pull request analysis in your Azure pipeline of code stored on Azure DevOps, you must configure a pull request trigger on the target branch (main development branch) as explained above in Enabling pull request analysis on target branch. If your code is stored on GitHub or Bitbucket Cloud, see below. 

Code stored on GitHub or Bitbucket Cloud

To configure a pull request trigger in your Azure build pipeline for code stored on GitHub or Bitbucket Cloud:

  1. Select Edit to modify your build pipeline.
  2. Go to the Triggers tab.
  3. Select the correct repository under Pull request validation.
  4. Select Enable pull request validation.
  5. Set up the branch filters: Note that this is the target branch of the pull request. See the Microsoft documentation for more details.
  6. Select Save to update your pipeline.

Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved.

Creative Commons License