• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SonarQube and Jenkins: what are the benefits of using them together?

 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to know what are the most important benefits of using SonarQube and Jenkins together.
 
darren hartford
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've partly used Sonar in a couple projects with Hudson/Jenkins, and the benefit comes from the historical trending aspects and 'goal setting'.

If the goal is to increase the quality of the project, you can not measure if you are going in the right direction or not without keeping a trend as you make changes -- hudson/jenkins with sonar seems to help in this direction.

I remember somewhat the ability to look at historical reports and compare them to current, but it was a little wonky in that I think you needed a dedicated sonar server versus just 'adding' sonar to your project? There was something about trending/historical didn't work quite like you would expect around build server and source control that the sonar server assisted with....

-Darren
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rogerio Kioshi wrote:I'd like to know what are the most important benefits of using SonarQube and Jenkins together.

My team uses Jenkins to kick off the Sonar task as part of our build. so every time a change is made to our code, Sonar gets updated and we can see any improvements that were made.

Burk
 
Patroklos Papapetrou
Author
Ranch Hand
Posts: 32
5
Java Netbeans IDE Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integrating Jenkins with SonarQube is a big step towards Continuous Inspection.
By automating SonarQube analysis ( let's say once a day ) you're sure that SonarQube is constantly fed with latest metrics and source code files.
This will allow you to keep all the historical data and look how quality evolves through time and which metrics are going up / down.
With SonarQube Jenkins plugin you can launch analysis in several ways. You can create a job just for that purpose ( that runs SonarQube analysis let's say once a day after the integration tests job ), you can add in an existing job an extra build step or if you're suing maven you can add a post-build step to run SonarQube.

To sum up, running SonarQune analysis manually once in a while it's ok, but you're missing the big picture which is Continuous Inspection of your source code and that's what Jenkins plugin offers.
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patroklos Papapetrou wrote:Integrating Jenkins with SonarQube is a big step towards Continuous Inspection.


Continuous Inspection sounds interesting. Rather than hijack this thread though, I'll post the question separately so it has it's own thread here.

Burk
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34198
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another benefit on top of what Patroklos listed is that you can run SonarQube without changing your Maven pom or Ant build file. All the SonarQube settings can be set within Jenkins. Which allows you to change them without changing your code.
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Another benefit on top of what Patroklos listed is that you can run SonarQube without changing your Maven pom or Ant build file. All the SonarQube settings can be set within Jenkins. Which allows you to change them without changing your code.

Jeanne,
No changes to the build file? That's interesting.

When I started experimenting with Sonar (before SonarQube) I had to create a new task in the ant build file to run the Sonar task. The task specified directories for source and test code, as well as all the libraries needed to do the analysis for Sonar to display.

Is the configuration done in a Jenkins plugin for SonarQube?

Thanks,
Burk

 
Patroklos Papapetrou
Author
Ranch Hand
Posts: 32
5
Java Netbeans IDE Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly Burk

You can specify all analysis properties in SonarQube Jenkins plugin as you do in sonar-runner, pom.xml or ant script.
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's great! Can you also add new projects to SonaQube from the plug-in?
 
Patroklos Papapetrou
Author
Ranch Hand
Posts: 32
5
Java Netbeans IDE Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the plugin acts just any other SonarQube client.
As soon as you run the first analysis on a project it will be created in SonarQube
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's good news. In another thread someone posted the steps to configure the SonarQube Runner command file. It looks like you can only point it at one project at a time, because you're setting the project root, name, key (for the db), etc.

I'm actually hoping that the instructions given were wrong or incomplete because it looks like you'd have to keep multiple copies of the command file if you wanted to analyze multiple projects, and that doesn't seem reasonable to me.

Burk
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34198
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Burk.
Right. In Hudson/Jenkins, you just click the "Sonar" button in your build configuration for a job. Or inherit from the build configuration of a parent job. If you do the later, it's literally nothing to configure!
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,
Clicking a button to configure a new project sounds very convenient. Will it also generate/export a sonar-project.property file?

Thanks,
Burk
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34198
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Burk Hufnagel wrote:Clicking a button to configure a new project sounds very convenient. Will it also generate/export a sonar-project.property file?

No. The key is you don't need a sonar-project.property file with the Hudson/Jenkins plugin. The project you are running the build against is automatically sent along to Sonar.
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:
Burk Hufnagel wrote:Clicking a button to configure a new project sounds very convenient. Will it also generate/export a sonar-project.property file?

No. The key is you don't need a sonar-project.property file with the Hudson/Jenkins plugin. The project you are running the build against is automatically sent along to Sonar.

Jeanne,
I understand that, but if you can export the sonar-project.property file that it's running against then you know what the configuration is - and can modify it if necessary.
It can also be checked into revision control so that if you need to reproduce or clone the SonarQube server, you've got all the configuration settings.
Does that seem reasonable, or is there a better way?

Thanks for helping me understand more,
Burk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic