Skip to end of metadata
Go to start of metadata

Table of Contents



You must have previously installed SonarQube Scanner for Jenkins and read Analyzing Code Source.

From this point, there are several ways of triggering a SonarQube analysis using the SonarQube Scanner for Jenkins, which are described next.

Configuring a SonarQube Scanner using environment variables

If the ability to inject SonarQube configurations as variables in jobs is enabled in the Jenkins' global configuration, you will have ability to activate it in your job. If multiple SonarQube instances are configured, you will be able to choose which one to use.

Press the help button to learn which variables you can use in your build.

You may then use any of the SonarQube Scanners to perform the analysis, such as Maven, Gradle, Ant, etc. An example using maven:

Triggering a Project Analysis with the SonarQube Scanner for MSBuild

When analyzing with SonarQube Scanner for MSBuild, there are typically 3 steps:

  • Preparation of the analysis (Begin Analysis)
  • Execution of a rebuild with MSBuild
  • Publishing of results (End Analysis)

The begin and end steps are specific job types provided by Sonar Jenkins Plugin:

To perform the rebuild with MSBuild ('msbuild /t:Rebuild'), either configure it with the Jenkins MSBuild plugin, or execute it as a Windows batch command.

Therefore, a typical configuration of a job will have 3 steps:

Triggering a Project Analysis with the SonarQube Scanner

Go to the Build section, click on Add build step and choose Invoke Standalone SonarQube Analysis:

Configure the SonarQube analysis. You can either point to an existing file or set the analysis properties directly in the Project properties field:

Triggering an Analysis with Maven

This build type is deprecated. Instead, it is recommended to inject the SonarQube installation as variables and use them in a standard Maven job.


On a Maven job, go to the 'Post-build Actions' section and click on 'Add post-build action':

Then configure this post-build action:

    • Choose the SonarQube Installation:

    • Fill in the 'Advanced...' parameters as needed:


  • No labels