sonarqube integration with jenkins for code analysis

0 Comment

Sonarqube Integration With Jenkins For Code Analysis

sonarqube is a opensource static code analysis tool. It is able to analyse code in about 30 different programming languages. it calculates a set of metrics like Complexity, Duplication’s, Coding Rules, Potential Bugs. It stores them in a database and shows them on a dashboard. In the following steps i will show you how sonarqube integration with Jenkins for code analysis.

Download Sonarqube Scanner Plugin For Jenkins

sonarqube scanner

To integrate jenkins with sonarqube we need sonar scanner plugin. So lets download and install sonarqube scanner plugin. To install sonarqube scanner plugin
go to manage jenkins ==>manage plugins==>click on available==>sonarqube scanner plugin
install this sonarqube scanner plugin

Add Sonarqube Server Details in Jenkins Configure Systemsonarqube integration with Jenkins for code analysis

integrate sonarqube with jenkinsAfter installing sonarqube scanner. we have to add sonarqube server details in jenkins server. For that go to manage jenkins==>configure system
here you can see sonarqube server section. Here add your sonarqube server details. Enter any name for your sonarqube server configuration, In server url enter sonarqube url and at server authentication token enter token which you got from sonarqube server and save it.

Configure Sonarqube Scanner In Global Tool Configurationsonarqube integration with Jenkins for code analysis

configure sonarqube in jenkins

Go to manage jenkins==>globaltool configuration==> here you can see SonarQube Scanner section. Click on add sonarqube scanner give it any name here i am giving my-sonarqube-scanner. Now we have to download sonarqube scanner for that we have two options. One is install automatically from jenkins or manually login to your jenkins server shell and download sonarqube scanner.
Here i am choosing install automatically so jenkins will automatically download sonarqube scanner. If you don’t choose install automatically you have to install sonarqube scanner manually and you have to enter the path of sonarqube scanner at SONAR_RUNNER_HOME.

and save it

Create Job and add SonarĀ  propertiessonarqube integration with Jenkins for code analysis

Now create one job and go to build step click on add build step and select invoke top level maven targets and give maven command as clean install. And click on add build step and select execute sonarqube scanner click on that. And you can see new window will open for sonar scanner properties.
Here you can mention properties in two ways, one is by giving the path of your sonar-project.properties in Path to project properties file section. Or manually giving the properties in Analysis properties section.
Here i am giving manually in Analysis properties section.

sonar scanner properties in jenkins tutorial

sonar.sources=/var/lib/jenkins/workspace/$JOB_NAME/<PROJECT_NAME>/src
Here project name is nothing but directory name of your project in git hub or bit bucket or SCM.

save the jobs that’s all we have successfully integrated sonarqube with jenkins. build the job you can see the code analysis in sonarqube server.

if you are using amazon ec2 instances you have to enable the 9000 port of sonarqube server from jenkins server ip otherwise jenkins cannot reach sonarqube server. now we have successfully done sonarqube integration with Jenkins for code analysis.

  • jenkins sonarqube localhost
  • sonarqube scanner for jenkins
  • sonarqube analysis properties jenkins
  • jenkins sonarqube code coverage
  • sonarqube jenkins plugin example
  • sonar_runner_home jenkins
  • download sonarqube plugin for jenkins
  • sonarqube tutorial for devops
  • sonarqube plugin for jenkins download
  • jenkins execute sonarqube scanner
  • sonarqube integration with jenkins for code analysis
[top]

Leave a Reply

Your email address will not be published. Required fields are marked *