Tuesday, April 22, 2014

Sonar and Sonar runner with Jenkins

Configure  Sonar and Sonar runner with Jenkins

1)Install sonar plugin in jenkins
2)Download sonarqube(http://www.sonarqube.org/downloads/) and unzip it  into C:\KB\sonar\sonarqube-4.1.2
3)Open sonar.properties file from conf folder and uncomment below properties

sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar

you will have to create sonar database

4))Open command prompt and type cd  C:\KB\sonar\sonarqube-4.1.2\bin\windows-x86-64

5) Run StartSonar.bat

6) Configure sonar through manage jenkins->configure system

7))Download sonar runner and unzip it intoC:\KB\sonar\sonar-runner-2.3
8)Open sonar-runner.bar file from bin folder.
add this line at start below set ERROR_CODE=0
set SONAR_RUNNER_HOME=C:\KB\sonar\sonar-runner-2.3
and replace existing set  PROJECT_HOME with set PROJECT_HOME=C:\Jenkins\jobs\\workspace\
9)Configure sonar through manage jenkins->configure system


10) Now open job configuration from jenkins for which you want to run sonar
 and in Add Build Step select Invoke Standalone Sonar Analysis


11)Save the configuration  and then run the build for job.

No comments: