Skip to content
mildis edited this page Nov 21, 2015 · 9 revisions

Installation

There is a pre-built package available here: sonar-gerrit-plugin. Or you can build it for yourself.
Clone this repository, package it and put the package to your sonar plugins directory.

mvn clean package
cp target/sonar-gerrit-plugin-2.2.2.jar $SONAR_DIR/extensions/plugins
$SONAR_DIR/bin/your-architecture-here/sonar.sh restart

Configure Jenkins

This plugin is intended to be used with Gerrit Trigger plugin: https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger on a Jenkins server. Then you should set up Sonar plugin in Jenkins.
Log in as admin, Manage Jenkins - Configure System - Sonar - Advanced… - Additional properties: add and adjust your settings:

-DGERRIT_SCHEME=http -DGERRIT_PORT=8080 -DGERRIT_USERNAME=sonar -DGERRIT_PASSWORD=sonar_password

or

-DGERRIT_SCHEME=ssh -DGERRIT_PORT=29418 -DGERRIT_USERNAME=sonar -DGERRIT_PASSWORD=ssh_passphrase -DGERRIT_SSH_KEY_PATH=/path/to/user/.ssh/private.key

NOTE : Gerrit v2.11+ is required to use SSH for posting reviews

Last step is to add Post-Build action - SonarQube™ to every Jenkin's job you want to.

Configure Gerrit

You need to be able to connect to Gerrit with a valid username and password through HTTP or HTTPS. You can also use SSH with a valid username and SSH key pair. User can be part of the Non-Interactive Users group. Plugin vote on Code-Review label. To vote on another label, add a new label on Gerrit and change the plugin settings

[label "Quality-Check"]
    function = MaxWithBlock
    value = -1 Issues to be corrected
    value =  0 No score
    value = +1 Code is clean
Clone this wiki locally