# SonarQube tasks for Azure Pipelines

## 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.

<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.

| **Task input** | **Description**                                                                                                                                                                                                                                                                                                                   | **Required in YAML file** |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `SonarQube`    | Name of the SonarQube service connection(s) (SonarQube Server Endpoint) to your Azure DevOps project. See **Adding SonarQube Server service connection to Azure Pipelines** in [Setting up project integration](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/setting-up-project-integration.md). | x                         |
| `scannerMode`  | <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>                                                                    | x                         |

</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.

| **Input**         | **Description**                                                                                                                                                                                                                                                                          | **Required in YAML file**  |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `extraProperties` | <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>\<key>=\<value></code><br>For example: <code>sonar.exclusions=\*\*/\*.bin</code></p> | x (to set the project key) |

</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](/sonarqube-server/2025.3/analyzing-source-code/analysis-parameters.md) for more information on the possible values and default-from-build values.

| **Task input**         | **Description**                                                                                                                                                                                                                                                                                                                                                                                | **Corresponding sonar property** | **Required in YAML file** |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------------- |
| `projectKey`           | <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> | `sonar.projectKey`               | x                         |
| `projectName`          | <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>                                                                                                                                                                                     | `sonar.projectName`              | <p><br></p>               |
| `projectVersion`       | The version of the SonarQube Server project.                                                                                                                                                                                                                                                                                                                                                   | `sonar.projectVersion`           | <p><br></p>               |
| `dotnetScannerVersion` | <p>The version of the SonarScanner for .NET to be downloaded. See <a data-mention href="/pages/pEMrqETeCsu8N6Exmb0Y">/pages/pEMrqETeCsu8N6Exmb0Y</a>.</p><p><strong>Default</strong>: The extension’s default version of the SonarScanner for .NET (the latest compatible version).</p>                                                                                                        | <p><br></p>                      | <p><br></p>               |

</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](/sonarqube-server/2025.3/analyzing-source-code/analysis-parameters.md) for more information on the possible values and default-from-build values.

| **Task input**      | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | **Corresponding sonar property** | **Required in YAML file** |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------------- |
| `cliSources`        | <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> | `sonar.sources`                  | x                         |
| `configMode`        | <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>                                                                                                                                                                                                                                                                                                                                                                                     | <p><br></p>                      | x                         |
| `cliScannerVersion` | <p>Version of the SonarScanner CLI to be downloaded. See <a data-mention href="/pages/pEMrqETeCsu8N6Exmb0Y">/pages/pEMrqETeCsu8N6Exmb0Y</a>.</p><p><strong>Default</strong>: The extension’s default version of the SonarScanner CLI (the last available version).</p>                                                                                                                                                                                                                                                                                                                                                                    | <p><br></p>                      | <p><br></p>               |
| `configFile`        | <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>                                                                                                                                                                                                                                                                                                                                                                                   | <p><br></p>                      | <p><br></p>               |
| `cliProjectKey`     | <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>                                                                                                                                                                    | `sonar.projectKey`               | x                         |
| `cliProjectName`    | <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>                                                                                                                                                                                                                                                                                                                                                     | `sonar.projectName`              | <p><br></p>               |
| `cliProjectVersion` | <p>Is used if <code>configMode</code> is set to <code>manual</code>.<br>The version of the SonarQube Server project.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | `sonar.projectVersion`           | <p><br></p>               |
| `extraProperties`   | <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>\<key>=\<value></code><br>For example: <code>sonar.exclusions=\*\*/\*.bin</code></p>                                                                                                                                                                                                                                                                          | <p><br></p>                      | <p><br></p>               |

</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 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="/pages/XTIg2IxG09BkFcFQGtbX">/pages/XTIg2IxG09BkFcFQGtbX</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 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](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/azure-pipelines-integration-overview.md)
* [Gradle or Maven project](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/gradle-or-maven-project.md)
* [.NET project](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/dotnet-project.md)
* [C family project](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/c-family-project.md)
* [JS, TS, Go, Python, PHP, etc. project](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/js-ts-go-python-php.md)
* [Using various features](/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/various-features.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/2025.3/devops-platform-integration/azure-devops-integration/adding-analysis-to-pipeline/sonarqube-tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
