分享

Jenkins+Sonar | 扛一肩记忆

 bananarlily 2014-07-23

----------------------
Reproduced statement:
This post is reprinted/referred from the articles of Meera's Blog:
http://meera-subbarao./2009/11/continuos-quality-using-sonar.html

and
http://meera-subbarao./2009/11/hudson-sonar-perfect-match.html

Notes:

Pls note that the Jenkins server mentioned in this article is setup in Windows, not Linux, But it has almost the same steps as in Linux.

Pls also note that, This article is also suitable for Hudson CI system.

About Jenkins/Hudson Sonar plugin, pls refer to:

http://docs./display/SONAR/Hudson+and+Jenkins+Plugin

In case you are using other CI servers(like CrouseControl, etc...), no need to panic. You can read a detailed documentation here for all the CI servers Sonar supports:

http://docs./display/SONAR/Continuous+Inspection

It totally requires just 5 simple steps if you have Jenkins/Hudson running as your CI(Continuous Integration) server to install and use Sonar. Yes, 5 simple steps is all you need to get a neat and intuitive dashboard from Sonar. So, lets see what those 5 simple steps are.

Step 1: Download, install and start the Sonar Server.

Download the latest Sonar release from here. Unzip the distribution to your favorite location, for e.g C:\dev\projects\sonar-1.11.1. Based on your platform, run the batch file or the shell script from within the bin folder. On windows, it is C:\dev\projects\sonar-1.11.1\bin\windows-x86-32\StartSonar.bat.

Open a web browser and browse to http://localhost:9000. The default login and password is admin/admin.

Step 2: Install and Configure Sonar plugin on Jenkins/Hudson.

Open your Jenkins/Hudson dashboard. Default is http://localhost:8080. Click on Manage Jenkins/Hudson -> Manage Plugins. Click now on the Available tab, you should see the Jenkins/Hudson Sonar Plugin. Check this plugin and click on the Install button at the far right hand corner.

Restart Jenkins/Hudson and you should be able to see the plugin in the Installed tab as shown below:

Next, configure the Sonar plugin from within Manage Jenkins/Hudson -> Configure System. I am using the default database, and so didn't make any changes here. However, if you are using a different database server, you need to provide the database URL, username, password and so on as shown below.

Step 3: Configure your Jenkins/Hudson Job

In order to activate Sonar on a project, click on Configure, and within the Post-build Actions, check Sonar and you should see the following properties. Fill those properties and Save this configuration.

Step 4: Build your project

Even though you don't require Maven to be used as a build tool for your project, Sonar does still require Maven to run. If Maven isn't installed, you can download and install Maven from here.

Force a build on your Job on the Hudson dashboard. If Maven is installed, you should be able to see the following output in the Console Output on Hudson dashboard.

Step 5: Browse to Sonar Dashboard

Once the build succeeds in the last step, browse to http://localhost:8080. And you should be able to see the Sonar Dashboard as such:

That's all it is to download, install, configure and get continuous quality updates from Jenkins/Hudson and Sonar. The above steps took me less than 15 minutes.

I am sure many of you are already using Sonar. I haven't used it with any of my clients yet. Hopefully, will do so soon. Share your thoughts if you are using Sonar.

More information about Code Static Check in CI system such Jenkins/Hudson, pls refer to this link(It lists a lot of tools of code static check):
https://wiki./dosearchsite.action?queryString=code+static+check

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多