Setting up SonarQube for CI/CD

SonarQube is a code analysis dashboard allowing you to monitor code quality for all your projects. In this post we will look at step by step guide in setting up SonarQube. SonarQube is one of the core tool in a CI/CD implementation.

1.    Download latest JRE /JDK ( 9 and above) and install on the VM

Oracle JRE

Oracle JRE
2.    Download latest version of SonarQube from below link

SonarQube

Sonarqube community
3.    Unzip the JRE / JDK and SonarQube to a particular folder ( for this document purpose <RootPath> = c:\
4.    Update the JAVA_HOME with the path to ‘bin’ folder of JRE/JDK , restart the server/ VM
Ev
5.    Open Command Prompt in Admin mode

6.    Go to the bin folder of the sonarqube folder
7.    <RootPath>\sonarqube-8.0\bin\windows-x86-64\
8.    Execute the command InstallNTService.bat
9.    Ensure a success message
InstallNTService
Sonarqube Started
10. Ensure ‘temp’ folder is deleted
unzip
11. Go to Windows Services and start service “sonarqube” , service will automatically start when VM (re)starts
SonarQube service
12. Navigate to http://<VM-IP>:9000
login
13. Login with username – password combination (admin-admin)
Final Screen
login

Quality Profile

A ‘Quality Profile’ in SonarQube is a set of rules enabled for a particular technology and/or programming language (C#, Java, Javascript etc.) . SonarQube provides multiple plugins for each technology with predefined rules. These rules needs to be reviewed and enabled based on the application under development so that you focus on fixing core issues w.r.t code quality.

Quality Gate

A ‘Quality Gate’ is a set of ‘Goals’ applied across projects so that project delivery can be measured across projects consistently. Below is one example of a Quality Gate that can be applied.

No. of Major Issues = 0

Code Unit testing Coverage % = 80%

Above Quality Gate will mark the project as a ‘fail’ if latest sonar execution analyses >0 issues or if the new code is not having relevant Unit test cases.

With SonarQube setup, you are now one step away for CI/CD implementation. Visit CI Process for more details.

1 thought on “Setting up SonarQube for CI/CD”

  1. Pingback: Introduction to CI Process - Blog

Comments are closed.