Start Free
SonarQube Community Build | DevOps platform integration | Azure DevOps integration | Adding analysis to Azure pipeline | SonarQube tasks for Azure Pipelines

SonarQube tasks for Azure Pipelines

On this page

This page describes the tasks supported by the Azure DevOps Extension for SonarQube Community Build you can use in your Azure build pipeline.

Prepare Analysis Configuration task

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.

Task inputs common to all modes

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

Task inputDescriptionRequired in YAML file
SonarQubeName of the SonarQube service connection(s) (SonarQube Endpoint) to your Azure DevOps project. See Adding SonarQube Community Build service connection to Azure Pipelines in Setting up Azure DevOps integration at the project level.x
scannerMode

The running mode of the Azure DevOps Extension for SonarQube Community Build.

Possible values:

  • dotnet: .NET mode, for .NET projects.
  • other: Maven / Gradle mode, for Maven and Gradle projects.
  • cli: CLI mode, for other projects.
x
Task inputs specific to the Maven / Gradle mode

The table below lists the Prepare Analysis Configuration task inputs specific to the Maven / Gradle mode of the Azure DevOps Extension for SonarQube Community Build.

InputDescriptionRequired in YAML file
extraProperties

Additional sonar properties to be passed to the scanner. A property is defined through a [key, value] pair.

Format: One [key, value] pair per line as follows:
<key>=<value>
For example: sonar.exclusions=**/*.bin

x (to set the project key)
Task inputs specific to the .NET mode

The table below lists the Prepare Analysis Configuration task inputs specific to the .NET mode of the Azure DevOps Extension for SonarQube Community Build. The Corresponding sonar property column indicates the sonar property that SonarQube Community Build will set with the input value. See the sonar property description in Analysis parameters for more information on the possible values and default-from-build values. 

Task inputDescriptionCorresponding sonar propertyRequired in YAML file
projectKey
  • If the project exists already in SonarQube Community Build (It is highly recommended to create your project first: see Creating your project): the project’s unique key (is displayed in SonarQube UI).
  • If the project doesn’t exist yet in SonarQube Community Build, it will be created with this key. Allowed characters are letters, numbers, -, _, ., and :, with at least one non-digit.
sonar.projectKeyx
projectName 

The name of the SonarQube Community Build project that will be displayed on the web interface. 

Default: projectKey input value (if no default-from-build value applies). 

sonar.projectName
projectVersionThe version of the SonarQube Community Build project.sonar.projectVersion
dotnetScannerVersion

The version of the SonarScanner for .NET to be downloaded. See Using a specific SonarScanner version.

Default: The extension’s default version of the SonarScanner for .NET (the latest compatible version).



Task inputs specific to the CLI mode

The table below lists the Prepare Analysis Configuration task inputs specific to the CLI mode of the Azure DevOps Extension for SonarQube Community Build. The Corresponding sonar property column indicates the sonar property that SonarQube Community Build will set with the input value. See the sonar property description in Analysis parameters for more information on the possible values and default-from-build values. 

Task inputDescriptionCorresponding sonar propertyRequired in YAML file
cliSources

The path to the root directory containing source files. The path can be absolute, or relative to the repository root. 

Warning:  The possible values are different from the sonar.sources property:

  • You can only set a single path.
  • The relative path must be relative to the repository root (and not the to the sonar.projectBaseDir property).
  • If you want to set a list of paths, define instead sonar.sources in the extraProperties input or in sonar-project.properties (see Choosing the configuration mode)

Default: .

sonar.sourcesx
configMode

Specifies the configuration mode. 

Possible values:

  • file (default): The configuration is stored in the file defined through the configFile input.
  • manual: The configuration is defined through the extraProperties input.

 x
cliScannerVersion

Version of the SonarScanner CLI to be downloaded. See [link]

Default: The extension’s default version of the SonarScanner CLI (the last available version).



configFile

Is used if configMode is set to file.
The path to the file containing your analysis configuration. Path can be absolute or relative to the repository root.

Default: sonar-project.properties



cliProjectKey

Is used if configMode is set to manual.

  • If the project exists already in SonarQube Community Build (It is highly recommended to create your project first: see Creating your project): the project’s unique key (is displayed in SonarQube UI).
  • If the project doesn’t exist yet in SonarQube Community Build, it will be created with this key. Allowed characters are letters, numbers, -, _, ., and :, with at least one non-digit.
sonar.projectKeyx
cliProjectName

Is used if configMode is set to manual.

The name of the SonarQube Community Build project that will be displayed on the web interface. 

Default: cliProjectKey input value  (if no default-from-build value applies). 

sonar.projectName
cliProjectVersionIs used if configMode is set to manual.
The version of the SonarQube Community Build project.
sonar.projectVersion
extraProperties

Is used if configMode is set to manual.

Additional sonar properties to be passed to the scanner. A property is defined through a [key, value] pair.

Format: One [key, value] pair per line as follows:
<key>=<value>
For example: sonar.exclusions=**/*.bin



Run Code Analysis task

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

The table below lists the task inputs.

Task inputDescription

jdkversion


The version of Java used by the scanner for analysis. See General requirements on scanner environment.

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.

Possible values:

  • JAVA_HOME: Use the value of the JAVA_HOME environment variable on the system. 
  • 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.
  • 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.

Default: JAVA_HOME

Publish Quality Gate Result task

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.

The table below lists the task inputs.

Task inputDescription
pollingTimeoutSec

The maximum time (in seconds) for the task to wait for the analysis results sent by SonarQube Community Build.

Default: 300


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