且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么要为Jenkins使用SonarQube插件,而不是简单地使用Maven目标声纳:声纳?

更新时间:2023-11-17 23:18:40

您当然可以做一个简单的mvn sonar:sonar,它将起作用.

另一方面,Jenkins的SonarQube插件可以使配置更容易.例如,您将能够在一个位置(Jenkins的配置部分)定义有关SonarQube服务器(URL,数据库用户和密码)或多个SonarQube服务器的信息,从而不必在任何地方重复. /p>

该插件还提供了即时运行SonarQube分析的功能(无需Maven):您只需要提供一些必填属性(例如sonar.projectKeysonar.projectVersion),该插件即可启动Java Standalone对您透明地运行Runner(这对Java以外的其他语言非常有用,Java不依赖于Maven进行构建.)

因此,如果您只是进行一些测试,则实际上不需要此插件.但是,如果要设置Jenkins的生产实例,那么***使用SonarQube插件.

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?

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.