# SonarQube tasks for Azure Pipelines

{% hint style="success" %}
Note that the [*Azure DevOps extension for SonarQube Cloud*](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) and the [*Azure DevOps extension for SonarQube Server*](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) are different extensions.&#x20;

Although they share tasks which function in the same way, these extensions have unique software releases and version numbers. Please see the relevant links in case you're on the wrong page now:

* The [Azure DevOps extension for SonarQube Cloud](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops) documentation
* The [Azure DevOps extension for SonarQube Server](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops) documentation
  {% endhint %}

Examples of each SonarQube task described on this page can be found in code samples located on pages in this section of the docs. Select your project type from the pages listed on the [](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline "mention") page, then read through the setup instructions to locate the example pipeline to reference.

For more information about customizing your Azure pipeline with the task inputs listed below, please see the [various-features](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/various-features "mention") page.

## Prepare Analysis Configuration task <a href="#prepare-analysis-configuration" id="prepare-analysis-configuration"></a>

This task configures the required settings before executing the build. For .NET solutions or Java projects, it helps integrate seamlessly with MSBuild, Maven, and Gradle tasks.

The Prepare Analysis Configuration task shows up in your Azure pipeline as task: `SonarQubePrepare@X`

* where `X` = the current version of the [sonarqube-extension-for-azure-devops](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops "mention") for SonarQube Server.

{% hint style="info" %}
Properties passed via `extraProperties` should be written without any prefix, for example `sonar.verbose=true`. The task invokes the scanner on your behalf and handles the prefix internally. For a full explanation of prefix conventions when passing properties to the SonarScanner for .NET, see [#passing-properties](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/dotnet/using#passing-properties "mention").
{% endhint %}

<details>

<summary>Task inputs common to all modes</summary>

The table below lists the **Prepare Analysis Configuration** task inputs common to all modes of the Azure DevOps Extension for SonarQube Server.

<table><thead><tr><th width="185.59375">Task input</th><th width="390.3924560546875">Description</th><th>Required in YAML file</th></tr></thead><tbody><tr><td><code>SonarQube</code></td><td>Name of the SonarQube service connection(s) (SonarQube Server Endpoint) to your Azure DevOps project. See <a data-mention href="../../project-integation#adding-sonarqube-service-connection">#adding-sonarqube-service-connection</a></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""></td></tr><tr><td><code>scannerMode</code></td><td><p>The running mode of the Azure DevOps extension for SonarQube Server.</p><p>Possible values:</p><p>• dotnet: .NET mode, for .NET projects.</p><p>• other: Maven / Gradle mode, for Maven and Gradle projects.</p><p>• cli: CLI mode, for other projects.</p></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""></td></tr></tbody></table>

</details>

<details>

<summary>Task inputs specific to the Maven / Gradle mode</summary>

The table below lists the **Prepare Analysis Configuration** task inputs specific to the Maven / Gradle mode of the Azure DevOps extension for SonarQube Server.

<table><thead><tr><th width="186.03515625">Task input</th><th width="389.870361328125">Description</th><th>Required in YAML file</th></tr></thead><tbody><tr><td><code>extraProperties</code></td><td><p>Additional sonar properties to be passed to the scanner. A property is defined through a [key, value] pair.</p><p><strong>Format</strong>: One [key, value] pair per line as follows:<br><code>&#x3C;key>=&#x3C;value></code><br>For example: <code>sonar.exclusions=**/*.bin</code></p></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""> (to set the project key)</td></tr></tbody></table>

</details>

<details>

<summary>Task inputs specific to the .NET mode</summary>

The table below lists the **Prepare Analysis Configuration** task inputs specific to the .NET mode of the Azure DevOps extension for SonarQube Server. The **Corresponding sonar property** column indicates the sonar property that SonarQube Server will set with the input value. See the sonar property description in [analysis-parameters](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/analysis-parameters "mention") for more information on the possible values and default-from-build values.

<table><thead><tr><th width="185.9140625">Task input</th><th width="212.1514892578125">Description</th><th width="185.9896240234375">Corresponding sonar property</th><th>Required in YAML file</th></tr></thead><tbody><tr><td><code>projectKey</code></td><td><p>• If the project exists already in SonarQube Server (It is highly recommended to create your project first: see Creating your project): the project’s unique key (is displayed in SonarQube UI).</p><p>• If the project doesn’t exist yet in SonarQube Server, it will be created with this key. Allowed characters are letters, numbers, -, _, ., and :, with at least one non-digit.</p></td><td><code>sonar.projectKey</code></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""></td></tr><tr><td><code>projectName</code></td><td><p>The name of the SonarQube Server project that will be displayed on the web interface.</p><p><strong>Default</strong>: <code>projectKey</code> input value (if no default-from-build value applies).</p></td><td><code>sonar.projectName</code></td><td><br></td></tr><tr><td><code>projectVersion</code></td><td>The version of the SonarQube Server project.</td><td><code>sonar.projectVersion</code></td><td><br></td></tr><tr><td><code>dotnetScannerVersion</code></td><td><p>The version of the SonarScanner for .NET to be downloaded. See <a data-mention href="various-features">various-features</a>.</p><p><strong>Default</strong>: The extension’s default version of the SonarScanner for .NET (the latest compatible version).</p></td><td><br></td><td><br></td></tr><tr><td><code>extraProperties</code></td><td><p>Additional sonar properties to be passed to the scanner. A property is defined through a [key, value] pair.</p><p><strong>Format</strong>: One [key, value] pair per line as follows:<br><code>&#x3C;key>=&#x3C;value></code><br>For example: <code>sonar.scanner.scanAll=false</code></p></td><td></td><td></td></tr></tbody></table>

</details>

<details>

<summary>Task inputs specific to the CLI mode</summary>

The table below lists the **Prepare Analysis Configuration** task inputs specific to the CLI mode of the Azure DevOps extension for SonarQube Server. The **Corresponding sonar property** column indicates the sonar property that SonarQube Server will set with the input value. See the sonar property description in [analysis-parameters](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/analysis-parameters "mention") for more information on the possible values and default-from-build values.

<table><thead><tr><th width="185.66015625">Task input</th><th width="212.434326171875">Description</th><th width="185.3028564453125">Corresponding sonar property</th><th>Required in YAML file</th></tr></thead><tbody><tr><td><code>cliSources</code></td><td><p>The path to the root directory containing source files. The path can be absolute, or relative to the repository root.</p><p><strong>Warning</strong>: The possible values are different from the <code>sonar.sources</code> property:</p><p>• You can only set a single path.</p><p>• The relative path must be relative to the repository root (and not the to the sonar.projectBaseDir property).</p><p>• If you want to set a list of paths, define instead sonar.sources in the extraProperties input or in sonar-project.properties (See Choosing your configuration mode)</p><p><strong>Default</strong>: <strong>.</strong></p></td><td><code>sonar.sources</code></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""></td></tr><tr><td><code>configMode</code></td><td><p>Specifies the configuration mode.</p><p>Possible values:</p><p>• file (default): The configuration is stored in the file defined through the configFile input.</p><p>• manual: The configuration is defined through the extraProperties input.</p></td><td><br></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""></td></tr><tr><td><code>cliScannerVersion</code></td><td><p>Version of the SonarScanner CLI to be downloaded. See [link]</p><p><strong>Default</strong>: The extension’s default version of the SonarScanner CLI (the last available version).</p></td><td><br></td><td><br></td></tr><tr><td><code>configFile</code></td><td><p>Is used if <code>configMode</code>is set to <code>file</code>.<br>The path to the file containing your analysis configuration. Path can be absolute or relative to the repository root.</p><p><strong>Default</strong>: sonar-project.properties</p></td><td><br></td><td><br></td></tr><tr><td><code>cliProjectKey</code></td><td><p>Is used if <code>configMode</code> is set to <code>manual</code>.</p><p>• If the project exists already in SonarQube Server (It is highly recommended to create your project first: see Creating your project): the project’s unique key (is displayed in SonarQube UI).</p><p>• If the project doesn’t exist yet in SonarQube Server, it will be created with this key. Allowed characters are letters, numbers, -, _, ., and :, with at least one non-digit.</p></td><td><code>sonar.projectKey</code></td><td><img src="https://3560343708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4FzELVjsPO4ijRo3jtBV%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media" alt=""></td></tr><tr><td><code>cliProjectName</code></td><td><p>Is used if <code>configMode</code> is set to <code>manual</code>.</p><p>The name of the SonarQube Server project that will be displayed on the web interface.</p><p><strong>Default</strong>: <code>cliProjectKey</code> input value (if no default-from-build value applies).</p></td><td><code>sonar.projectName</code></td><td><br></td></tr><tr><td><code>cliProjectVersion</code></td><td>Is used if <code>configMode</code> is set to <code>manual</code>.<br>The version of the SonarQube Server project.</td><td><code>sonar.projectVersion</code></td><td><br></td></tr><tr><td><code>extraProperties</code></td><td><p>Is used if <code>configMode</code> is set to <code>manual</code>.</p><p>Additional sonar properties to be passed to the scanner. A property is defined through a [key, value] pair.</p><p><strong>Format</strong>: One [key, value] pair per line as follows:<br><code>&#x3C;key>=&#x3C;value></code><br>For example: <code>sonar.exclusions=**/*.bin</code></p></td><td><br></td><td><br></td></tr></tbody></table>

</details>

## Run Code Analysis task <a href="#run-code-analysis" id="run-code-analysis"></a>

This task executes the analysis of the source code. It is not used in the Gradle / Maven mode of the Azure DevOps extension for SonarQube Server.

The Run Code Analysis task shows up in your Azure pipeline as task: `SonarQubeAnalyze@X`

* where `X` = the current version of the [sonarqube-extension-for-azure-devops](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops "mention") for SonarQube Server.

The table below lists the task inputs.

| Task input                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>jdkversion</code></p><p><br></p> | <p>The version of Java used by the scanner for analysis. See <a data-mention href="../../../analyzing-source-code/scanners/scanner-environment/general-requirements">general-requirements</a>.</p><p>If you select a value other than JAVA\_HOME, the analyze task will revert to using JAVA\_HOME if the selected environment variable does not exist.</p><p>Possible values:</p><p>• JAVA\_HOME: Use the value of the JAVA\_HOME environment variable on the system.</p><p>• JAVA\_HOME\_17\_X64: Use the value of the JAVA\_HOME\_17\_X64 environment variable on the system, if available. This environment variable is already set when running on Microsoft-hosted agents.</p><p>• JAVA\_HOME\_21\_X64: Use the value of the JAVA\_HOME\_17\_X64 environment variable on the system. This environment variable is already set when running on Microsoft-hosted agents.</p><p><strong>Default</strong>: <code>JAVA\_HOME</code></p> |

## Publish Quality Gate Result task <a href="#publish-quality-gate-result" id="publish-quality-gate-result"></a>

This task allows you to report the quality gate status directly to your Azure Pipeline’s Build Summary page. It is not mandatory but highly recommended.

{% hint style="info" %}
The Publish Quality Gate Result task can significantly increase the overall build time because it will poll SonarQube until the analysis is complete.
{% endhint %}

The Publish Quality Gate Result task shows up in your Azure pipeline as task: `SonarQubePublish@X`

* where `X` = the current version of the [sonarqube-extension-for-azure-devops](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops "mention") for SonarQube Server.

The table below lists the task inputs.

| Task input          | Description                                                                                                                                      |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pollingTimeoutSec` | <p>The maximum time (in seconds) for the task to wait for the analysis results sent by SonarQube Server.</p><p><strong>Default</strong>: 300</p> |

## Related pages <a href="#related-pages" id="related-pages"></a>

* [azure-pipelines-integration-overview](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/azure-pipelines-integration-overview "mention")
* [gradle-or-maven-project](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/gradle-or-maven-project "mention")
* [dotnet-project](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/dotnet-project "mention")
* [c-family-project](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/c-family-project "mention")
* [js-ts-go-python-php](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/js-ts-go-python-php "mention")
* [various-features](https://docs.sonarsource.com/sonarqube-server/2025.1/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/various-features "mention")
