Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use SonarQube plugin for Jenkins rather than simply use maven goal sonar:sonar?

Tags:

I want to launch SonarQube analysis with Jenkins for a Maven 2 project. I first used the goal sonar:sonar in the build configuration.

But I just found the SonarQube plugin for Jenkins. Why use it? Is it a better practice and why?

like image 972
Pith Avatar asked May 21 '12 15:05

Pith


People also ask

Why should we need to integrate SonarQube and Jenkins?

Basically Integrating SonarQube and Jenkins provides you the ability to analyze your code when you run a job which contains SonarQube execution within it and generates an analysis of that code in your SonarQube Server.

What is the use of SonarQube in Jenkins?

This plugin lets you centralize the configuration of SonarQube server connection details in Jenkins global configuration. Then you can trigger SonarQube analysis from Jenkins using standard Jenkins Build Steps or Jenkins Pipeline DSL to trigger analysis with: SonarScanner.

Can we use SonarQube without Jenkins?

You have to build the project manually and set the sonar. binaries property to your class files. If you never want to build the project, then you can use the SourceMeter plugin for SonarQube too. It only needs the source files, but can produce more metrics and issues if you needed.


1 Answers

You can of course do a simple mvn sonar:sonar, this will work.

On the other side, there's the SonarQube plugin for Jenkins that will make the configuration easier. For instance you will be able to define information about your SonarQube server (URL, DB user and password) or your multiple SonarQube servers in a single place (the configuration section of Jenkins) so that you don't have to repeat it everywhere.

The plugin also offers the ability to run a SonarQube analysis on the fly (without Maven): you just have to provide some mandatory properties (like sonar.projectKey and sonar.projectVersion for instance) and the plugin will start the Java Standalone Runner transparently for you (this is helpful mostly for other languages than Java which don't rely on Maven for their build).

So if you're just making some tests, you don't really need this plugin. But if you're setting up a production instance of Jenkins, then it's best to use the SonarQube plugin.

like image 136
Fabrice - SonarSource Team Avatar answered Sep 19 '22 14:09

Fabrice - SonarSource Team