I want to launch sonar analysis with Jenkins for a Maven 2 project. I first used the goal "sonar:sonar" in the build configuration. But I just found the sonar plugin for Jenkins. Why use it ? Is it a better pratice and why ?
问题:
回答1:
You can of course do a simple "mvn sonar:sonar", this will work.
On the other side, there's the Sonar plugin for Jenkins that will make the configuration easier. For instance you will be able to define information about your Sonar server (URL, DB user and password) or your multiple Sonar 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 Sonar 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 Sonar plugin.