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
To setup sonar you can find details from here
Sonar can process your project code by two ways :
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
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.