Integrate Sonar in Jenkins

Posted By : Ankit Gupta | 11-Dec-2014

Jenkins tool is used for auto build,deployment and sonar is a good tool to manage code quality.

 

Here I am going to explain how we can integrate sonar with jenkins auto build process.

 

Downlaod and Install sonarquebe
http://www.sonarqube.org/downloads/

 

To setup sonar you can find details from here
http://www.oodlestechnologies.com/blogs/Configure-SonarQube-for-Groovy-Grails-projects

 

Sonar can process your project code by two ways :
1. Sonarrunner
2. Maven

 

Here we will use maven for project code scanning.

Install mvn and your project should have proper pom.xml file.

 

Add following properties in pom.xml

 

 
        
            false
            src,java
         
 

Sonar.sources are directories which conatins your source code.

Now you have to setup a profile in mvn setting xml.

Go to settings.xml,in linux system it is in /usr/share/maven/conf directory.

 

Now add a profile in settings.xml

        
            sonar
            
                true
            
            
                
                
                  jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
                
                sonar
                sonar
 
                
                
                  http://myserver:9000
                
            
        

 

You have to run mysql server and set up a database for sonar reports storage,Update database,username etc. in profile.

Now maven is ready to work with sonar.

Add sonar plugin in jenkins and add a PostBuildAction in your jenkins project.

Start the sonar server and build from jenkins,you will get sonar reports.

Thanks!!!

 

About Author

Author Image
Ankit Gupta

Ankit is a lead java developer well experienced in development of web and enterprise level applications. He has good exposure to enterprise frameworks like Drools , Opta-planner , jBilling and graph databases like Neo4J etc.

Request for Proposal

Name is required

Comment is required

Sending message..