Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get link to Sonar dashboard in Jenkins when calling 'gradle sonarRunner'

With the Jenkins build step Invoke Standalone Sonar Analysis (which is available via the Sonar plugin) you get this nice link to the SonarQube dashboard in the job overview: sonar link.

I'm not using this build step due to an issue but rather have a build step that calls gradle sonarRunner: gradle sonarRunner

This is the part of my build.gradle configuring Sonar:

sonarRunner {
    sonarProperties {
    property "sonar.projectKey", projectId
    property "sonar.projectName", projectName

    // Address of SonarQube server
    property "sonar.host.url", "http://localhost:9000"

    // Database config
    property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true"
    property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
    property "sonar.jdbc.username", "root"
    property "sonar.jdbc.password", "superSecret"
    }
}

This works great: Just as with the Invoke Standalone Sonar Analysis build step, I can browse SonarQube's results at http://localhost:9000/dashboard/index/jutilsId.

Unfortunately, this way the link to the SonarQube dashboard is gone from Jenkins' job overview.

This blog entry describes how to achieve what I want but seems to be outdated as I can find no option in SonarQube's configuration that says Check if this project is NOT built with maven 2.

Is there any way I can have this link and use gradle sonarRunner?


My system:

I'm using SonarQube Server 4.1.1, Gradle Plugin 1.23, Sonar Plugin 2.1, Sonar Runner 2.3 and gradle --version gives:

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------

Build time:   2013-12-17 09:28:15 UTC
Build number: none
Revision:     36ced393628875ff15575fa03d16c1349ffe8bb6

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.7.0_21 (Oracle Corporation 23.7-b01)
OS:           Linux 3.10-2-486 i386
like image 877
Matthias Braun Avatar asked Feb 16 '14 17:02

Matthias Braun


1 Answers

Sidebar-Link Plugin to the rescue!

  1. Install the plugin.
  2. Put the sonar icon into /var/lib/jenkins/userContent. That's inside JENKINS_HOME. If you don't know where JENKINS_HOME is, take a look in the config file at /etc/default/jenkins.

  3. Set up the link like this in the job's configuration (your URL will be different): sidebar link config

  4. Done
like image 187
Matthias Braun Avatar answered Oct 04 '22 16:10

Matthias Braun