Gradle or Maven project
Using YAML or the Azure Classic editor to create the Azure build pipeline with new Gradle or Maven tasks.
Before you begin, see the Azure Pipelines integration overview page.
Once you have created and set up your SonarQube Community Build project, check out the Creating and configuring your project and Setting up project integration pages for information about adding the SonarQube analysis to your Azure build pipeline.
To create your Azure build pipeline, you can use either YAML or the Azure Classic editor.
About the analysis parameter setup
Analysis parameters can be set at different levels; see the Configuring the project analysis parameters article for details. You must define the project key in the Prepare Analysis Configuration task of your pipeline. You may define additional parameters in this task the same way. In that case, these parameters have precedence over parameters defined at the project or global level.
Using YAML
Add the SonarQube analysis run to your build task.
Add the following SonarQube tasks:
Before your build task, add a Prepare Analysis Configuration task.
After your build task, add a Run Code Analysis task.
After the Rune Code Analysis task, add a Publish Quality Gate Result task.
See the YAML file example below. See also our YAML pipeline templates. For information about the SonarQube task inputs, check the SonarQube tasks for Azure Pipelines page.
Using the Classic editor
1. In the Azure DevOps’ Classic editor, create or update your build pipeline.
2. Add a Prepare Analysis Configuration task before your build task:
In SonarQube Service Endpoint, select the SonarQube Server service connection you created during setup. See the Setting up project integration page for more information about adding a connection.
Under Choose a way to run the analysis, select Integrate with Maven or Gradle.
Expand the Advanced section and replace the Additional Properties with the following snippet:
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
sonar.projectKey=<YourProjectKey>
sonar.projectName=<YourProjectName>3. Add a new Maven or Gradle task:
Under Code Analysis, check Run SonarQube or SonarCloud Analysis.
4. Add a new Publish quality gate result task on your build pipeline summary.
5. Ensure that the pipeline runs automatically for all the branches you want: Under the Triggers tab of your pipeline, select Enable continuous integration and select all the branches for which you want SonarQube Community Build analysis to run automatically.
6. Save your pipeline.
Related pages
Using various features when adding the analysis to your pipeline
Last updated
Was this helpful?

