SonarQubePrepare@7 - Prepare Analysis Configuration v7 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 v7
# Prepare SonarQube Server analysis configuration.
- task: SonarQubePrepare@7
  inputs:
    SonarQube: # string. Required. SonarQube Server Endpoint. 
    scannerMode: 'dotnet' # 'dotnet' | 'cli' | 'other'. Required. Choose the way to run the analysis. Default: dotnet.
    #msBuildVersion: # string. Alias: dotnetScannerVersion. Optional. Use when scannerMode = dotnet. .NET Scanner Version. 
    #cliVersion: # string. Alias: cliScannerVersion. 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 = dotnet. Project Key. 
    #cliProjectName: # string. Optional. Use when scannerMode = cli && configMode = manual. Project Name. 
    #projectName: # string. Optional. Use when scannerMode = dotnet. 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 = dotnet. 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: dotnet (Integrate with .NET), cli (Use standalone SonarScanner CLI), other (Integrate with Maven or Gradle). Default value: dotnet.

  • dotnet (Integrate with .NET)
    • Put this task before your build task
    • Add the 'Run Code Analysis' task after the MSBuild/VSTest tasks
  • other (Integrate with Maven or Gradle)
    • Put this task before the Maven/Gradle task
    • Tick the 'Run SonarQube Analysis' checkbox in the Maven/Gradle task configuration.
  • cli
    • 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 - .NET Scanner Version
Input alias: dotnetScannerVersion. string. Optional. Use when scannerMode = dotnet.

Specify the version of the .NET Scanner to use. Versions can be located here.


cliVersion - Scanner CLI Version
Input alias: cliScannerVersion. 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 = dotnet.

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

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