SonarQubePrepare@6 - Prepare Analysis Configuration v6 task
Prepare SonarQube analysis configuration.
Note
The SonarQube tasks are part of the SonarQube extension for Azure DevOps, which is pre-installed in Azure DevOps Services. For more information and support for SonarQube and SonarQube tasks, see SonarQube extension for Azure DevOps, SonarQube - Visual Studio Marketplace, and Sonar Community.
Syntax
# Prepare Analysis Configuration v6
# Prepare SonarQube analysis configuration.
- task: SonarQubePrepare@6
inputs:
SonarQube: # string. Required. SonarQube Server Endpoint.
scannerMode: 'MSBuild' # 'MSBuild' | 'Other' | 'CLI'. Required. Choose the way to run the analysis. Default: MSBuild.
#msBuildVersion: # string. Optional. Use when scannerMode = MSBuild. Scanner MSBuild Version.
#cliVersion: # string. Optional. Use when scannerMode = CLI. Scanner CLI Version.
#configMode: 'file' # 'file' | 'manual'. Required when scannerMode = CLI. Mode. Default: file.
#configFile: 'sonar-project.properties' # string. Optional. Use when scannerMode = CLI && configMode = file. Settings File. Default: sonar-project.properties.
#cliProjectKey: # string. Required when scannerMode = CLI && configMode = manual. Project Key.
projectKey: # string. Required when scannerMode = MSBuild. Project Key.
#cliProjectName: # string. Optional. Use when scannerMode = CLI && configMode = manual. Project Name.
#projectName: # string. Optional. Use when scannerMode = MSBuild. Project Name.
#cliProjectVersion: '1.0' # string. Optional. Use when scannerMode = CLI && configMode = manual. Project Version. Default: 1.0.
#projectVersion: '1.0' # string. Optional. Use when scannerMode = MSBuild. Project Version. Default: 1.0.
#cliSources: '.' # string. Required when scannerMode = CLI && configMode = manual. Sources directory root. Default: ..
# Advanced
#extraProperties: # string. Additional Properties.
Inputs
SonarQube
- SonarQube Server Endpoint
string
. Required.
Select the SonarQube server endpoint for your project. To create one, click the Manage link and create a new SonarQube Server Endpoint, enter your server url and token.
scannerMode
- Choose the way to run the analysis
string
. Required. Allowed values: MSBuild
(Integrate with MSBuild), Other
(Integrate with Maven or Gradle), CLI
(Use standalone scanner). Default value: MSBuild
.
MSBuild
- Put this task before your MSBuild task
- Add the 'Run Code Analysis' task after the MSBuild/VSTest tasks
Maven/Gradle
- Put this task before the Maven/Gradle task
- Tick the 'Run SonarQube Analysis' checkbox in the Maven/Gradle task configuration.
Others
For other cases you can use the standalone scanner (sonar-scanner) and set all configuration with this task, and then add the 'Run Code Analysis' task.
msBuildVersion
- Scanner MSBuild Version
string
. Optional. Use when scannerMode = MSBuild
.
Specify the version of the MSBuild scanner to use. Versions can be located here.
cliVersion
- Scanner CLI Version
string
. Optional. Use when scannerMode = CLI
.
Specify the version of the CLI scanner to use. Versions can be located here.
configMode
- Mode
string
. Required when scannerMode = CLI
. Allowed values: file
(Store configuration with my source code (sonar-project.properties)), manual
(Manually provide configuration). Default value: file
.
Choose your preferred configuration method.
configFile
- Settings File
string
. Optional. Use when scannerMode = CLI && configMode = file
. Default value: sonar-project.properties
.
More information is available here.
cliProjectKey
- Project Key
string
. Required when scannerMode = CLI && configMode = manual
.
The SonarQube project unique key, i.e. sonar.projectKey
.
projectKey
- Project Key
string
. Required when scannerMode = MSBuild
.
The SonarQube project unique key, i.e. sonar.projectKey
.
cliProjectName
- Project Name
string
. Optional. Use when scannerMode = CLI && configMode = manual
.
The SonarQube project name, i.e. sonar.projectName
.
projectName
- Project Name
string
. Optional. Use when scannerMode = MSBuild
.
The SonarQube project name, i.e. sonar.projectName
.
cliProjectVersion
- Project Version
string
. Optional. Use when scannerMode = CLI && configMode = manual
. Default value: 1.0
.
The SonarQube project version, i.e. sonar.projectVersion
.
projectVersion
- Project Version
string
. Optional. Use when scannerMode = MSBuild
. Default value: 1.0
.
The SonarQube project version, i.e. sonar.projectVersion
.
cliSources
- Sources directory root
string
. Required when scannerMode = CLI && configMode = manual
. Default value: .
.
Path to the root directory containing source files. This value is set to the sonar.sources
SonarQube property.
extraProperties
- Additional Properties
string
. Default value: # Additional properties that will be passed to the scanner, \n# Put one key=value per line, example:\n# sonar.exclusions=**/*.bin
.
Additional properties to be passed to the scanner. Specify each key=value pair on a new line.
Task control options
All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.
Output variables
None.
Remarks
Note
The SonarQube tasks are part of the SonarQube extension for Azure DevOps, which is pre-installed in Azure DevOps Services. For more information and support for SonarQube and SonarQube tasks, see SonarQube extension for Azure DevOps, SonarQube - Visual Studio Marketplace, and Sonar Community.
Requirements
Requirement | Description |
---|---|
Pipeline types | YAML, Classic build |
Runs on | Agent, DeploymentGroup |
Demands | None |
Capabilities | This task does not satisfy any demands for subsequent tasks in the job. |
Command restrictions | Any |
Settable variables | Any |
Agent version | 3.218.0 or greater |
Task category | Build |