Integrate SonarQube with Jenkins

This blog will show you how you can integrate SonarQube with Jenkins, You can implement various quality gates using SonarQube based on your needs and configure the code analysis to be done by SonarQube so the code should pass the quality gate to continue with the CI pipeline 

Step 1: Login to your Jenkins controller and install SonarQube plugin

Go to Manage Jenkins > Manage Plugins

Click on Available > Type SonarQube Scanner for Jenkins and hit enter > Click on Install without restart

Step 2: Login to SonarQube and generate a security token

Click on your profile > My Account

Go to Security > Give a Token Name > Generate

Click on Copy ( You wont be able to see the key if the page gets refreshed )

Step 3: Login to Jenkins and perform the Integration

Go to Manage Jenkins > Global Tool Configuration

Scroll down to SonarQube Scanner > Click on Add SonarQube Scanner > Give a Name ( This name will be used in the Pipeline code when implementing CI ) > Click on Save

Go Back to Manage Jenkins > Configure System

Scroll down to SonarQube servers > Click on Add SonarQube

Give a NameServer URL ( SonarQube Server IP ) > Click on Add 

Note:

  • Make sure Jenkins is able to communicate with SonarQube Server ( Check firewall rules )
  • Sometimes you might need to Click on Save ( If the Add option is not responding ) , then comeback to the same section 

Click on Add > Jenkins > Select Secret text

Copy the Token Key which was generated in Step 2 and paste it in Secret field > Give an ID and Description > Click on Add > Save 
That’s it !!! Now you have integrated Jenkins with SonarQube server which you can now use in your CI pipeline for Code Analysis
 

Add a Comment

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