This page documents how to trigger a Sonar analysis from a Jenkins job for versions prior to 2.0. For versions 2.0+, browse this documentation page. |
Depending on you are using or not Maven jobs, there are three different methods for activating Sonar analysis.
Activate Sonar analysis on Maven jobs
If your using a Maven jobs, you just need to add a Post-build action on your project :

Then configure it :

Here is the list of properties :
Properties | Explanation |
|---|---|
Branch | Two branches of the same project are considered as different projects in Sonar. |
Language | Sets the language of source code. By default, Sonar is using Java source code analysers. If a Sonar plugin allows to analyse another given language, the associated source code analysers can be activated |
MAVEN_OPTS | Allow to set the parameters used by Maven such as -Xmx512m |
Additional properties | You can add any additional properties here. The properties used by Sonar are described here |
You can also override here the default triggers action if the global action does not fit to your project. You will find the same values as in Configuring Sonar Jenkins Plugin
Activate Sonar analysis on non-Maven jobs
If you are not using the Maven build process, you can still use this plugin to activate the analysis.
On your project add a Build step :

Then configure it :

The parameters are :
Paramater | Explanation |
|---|---|
Path to project properties | Relative path of the properties file. |
Project properties | Here you can set the properties without the need of the properties file. The values here will will take precedence over the ones defined eventually in the project properties file |
JVM_OPTIONS | Allow to set the JVM parameters used the Sonar Runner when it will be executed |
The properties are :
Properties | Mandatory | Explanation |
|---|---|---|
sonar.projectKey | yes | The key used to identify a project |
sonar.projectName | yes | The name of the project |
sonar.projectVersion | yes | The version of the project |
sources | yes | A comma separated list of source directories |
tests | no | A comma separated list of test directories |
binaries | no | A path to the project binaries |
libraries | no | A path to the project libraries |
sonar.java.source | no | 1.5 or 1.6 to turn up some features available on 1.5 or 1.6 |
sonar.java.target | no | 1.5 or 1.6 to turn up some features available on 1.5 or 1.6 |
sonar.language | no | The language to analyze (default: java) |
my.property | no | Some other properties |
This Build step will launch the Sonar Runner.
Activate Sonar analysis by Ant task
This plugin is useless if you are using the Ant task to define analysis of your projects.
Indeed all the information about the Sonar server will be defined in your Ant build file as explained here.

