Thursday, June 21, 2012

Integrate Sonar with Hudson


Issue: How to Integrate SONAR with Hudson?

Recently I have just come to know about SONAR. This is code reviewing tool. Currently we are using hudson as CI tool. Now we need to integrate SONAR with hudson. So that whenever someone check-in code, then it will be reviewed by SONAR before making a build. 

Note : I will update later about Hudson and SONAR Installation and configuration. For the time being I am just updating about SONAR integration with hudson. If someone already configured Hudson, then it'll be helpful for them.

Resolution:
Actually this is having some simple steps. Hudson provide a plugin for SONAR and we need maven installed and configured with hudson for this.So below are the steps:

Step 1: Download, install and start the Sonar Server. 
Download the latest Sonar release from here. Unzip the distribution to your favorite location. Based on your platform, run the batch file or the shell script from within the bin folder.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 Hudson.
Open your Hudson dashboard http://IP:port. Click on Manage Hudson - Manage Plugins. Click now on the Available tab, you should see the Hudson Sonar Plugin. Check this plugin and click on the Install button at the far right hand corner. Restart Hudson and you should be able to see the plugin in theInstalled tab as shown below:

Next, configure the Sonar plugin from within Manage Hudson -> Configure System and Change all required parameters.




Step 3: Configure your 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 theConsole Output on Hudson dashboard.

 

Step 5: Browse to Sonar Dashboard
Once the build succeeds in the last step, browse to http://localhost:9000(change port and localhost as per your environments that you have configured). And you should be able to see the Sonar Dashboard.


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



No comments:

Post a Comment

Integrate Jenkins with Azure Key Vault

Jenkins has been one of the most used CI/CD tools. For every tool which we are using in our daily life, it becomes really challenges when ...