Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: SonarQube link missing from job page's side bar

In the past, I configured Sonar in Jenkins by doing "Add post-build action -> SonarQube".

Now, when I do so, I get this warning:

It is no longer recommended to use SonarQube maven builder. It is preferable to set up SonarQube in the build environment and use a standard Jenkins maven target.

To fix this, I use this Maven plugin

<plugin>
    <groupId>org.sonarsource.scanner.maven</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>3.0.1</version>
</plugin>

and in the Jenkins job, I execute the following goals

-U clean test site sonar:sonar -Dsonar.host.url=http://my-sonar-server

Everything works flawlessly, except that the SonarQube link is missing from the side bar in the job page.

When I check the log, I see the SonarQube link:-

[INFO] Analysis report generated in 162ms, dir size=52 KB
[INFO] Analysis reports compressed in 47ms, zip size=27 KB
[INFO] Analysis report uploaded in 81ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://my-sonar-server/dashboard/index/org.project.test:test-webapp-war
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://my-sonar-server/api/ce/task?id=AVJgoenzoxKSuOBz_89b
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:46 min
[INFO] Finished at: 2016-01-20T14:02:50-06:00
[INFO] Final Memory: 67M/309M
[INFO] ------------------------------------------------------------------------

It appears I can add do "Add build step -> Invoke Standalone SonarQube Analysis", which will make this SonarQube link to appear, but it requires me to specify all the analysis properties manually and I find that very tedious since the sonar-maven-plugin handles that seamlessly for me.

My question is, using sonar-maven-plugin and my given goals above, how do I force Jenkins to display the SonarQube link on the job page's side bar?

I'm using Jenkins 1.645 and SonarQube 5.3.

like image 220
limc Avatar asked Jan 20 '16 20:01

limc


Video Answer


2 Answers

You just simply tick the Sidebar Links option on build configuration as shown here and put the Sonar scan linked to your project.

like image 87
Ronald Avatar answered Oct 13 '22 12:10

Ronald


  • Go to Manage Jenkins > Global Configuration
  • Check "Enable injection of Sonarqube server configuration as build environment variable" inside
  • Check "Prepare SonarQube Scanner environment" under Build Environment of the project configuration page
like image 30
AlwaysALearner Avatar answered Oct 13 '22 12:10

AlwaysALearner