7

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
limc
  • 39,366
  • 20
  • 100
  • 145
  • 1
    I don't know the solution but wondering why the link is important? Since it is a static link, can you not put in the job's description page? – Miserable Variable Jan 20 '16 at 20:33

2 Answers2

1

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

Laurel
  • 5,965
  • 14
  • 31
  • 57
Ronald
  • 11
  • 1
1
  • 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
AlwaysALearner
  • 335
  • 8
  • 23
  • I tried this solution the icon appears but is empty and in my execution job log I have the message : "Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project xxx : Not authorized. Please check the properties sonar.login and sonar.password." I also try with the maven goal : "clean install sonar:sonar -Djversion=${BUILD_NUMBER} -Dsonar.login=${SONAR_AUTH_TOKEN}" But same error. Any idea to help me ? – ThierryC Dec 20 '18 at 14:13