aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes SonarQube and Jenkins: what are the benefits of using them together? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "SonarQube and Jenkins: what are the benefits of using them together?" Watch "SonarQube and Jenkins: what are the benefits of using them together?" New topic
Author

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

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
I'd like to know what are the most important benefits of using SonarQube and Jenkins together.


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
darren hartford
Greenhorn

Joined: May 17, 2010
Posts: 17
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

Joined: Oct 01, 2001
Posts: 814
    
    3
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


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Patroklos Papapetrou
Author
Ranch Hand

Joined: Aug 06, 2013
Posts: 32
    
    5

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.


Follow me on twitter ( @ppapapetrou76 ) or see my linked profile and connect with me
You can slso subscribe to my technical blog
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
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

Joined: May 26, 2003
Posts: 31067
    
232

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
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

Joined: Aug 06, 2013
Posts: 32
    
    5

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

Joined: Oct 01, 2001
Posts: 814
    
    3
That's great! Can you also add new projects to SonaQube from the plug-in?
Patroklos Papapetrou
Author
Ranch Hand

Joined: Aug 06, 2013
Posts: 32
    
    5

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

Joined: Oct 01, 2001
Posts: 814
    
    3
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

Joined: May 26, 2003
Posts: 31067
    
232

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

Joined: Oct 01, 2001
Posts: 814
    
    3
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

Joined: May 26, 2003
Posts: 31067
    
232

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

Joined: Oct 01, 2001
Posts: 814
    
    3
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SonarQube and Jenkins: what are the benefits of using them together?