SonarQube Integration with Jenkins

Aman Pasi
2 min readSep 27, 2020

In this article we are going to create a Pipeline using Jenkins in which we will analyse the code using SonarQube on an Ubuntu Instance.

Step 1: Update Ubuntu and install openjdk 11 for Jenkins

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install default-jdk
$ sudo apt-get install wget
$ wget -q -O — https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
$ sudo sh -c ‘echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list’
$ sudo apt-get update
$ sudo apt-get install jenkins

After installing
$ sudo systemctl start jenkins

Open your jenkins on port 8080
https://localhost:8080 and get the temperory password from file stored at “/var/lib/jenkins/secrets/initialAdminPassword”
$ cat /var/lib/jenkins/secrets/initialAdminPassword
and install default plugins and configure new password.

Step 2: Installing SonarQube

Download SonarQube Community Edition from https://www.sonarqube.org/downloads/.

For installing SonarQube, It is good to use a database server for storing SonarQube information.
For installing with dedicated Database you can refer to https://www.vultr.com/docs/how-to-install-sonarqube-on-ubuntu-16-04

Since I am going to install it for testing only I am using default DB which comes with SonarQube…

For installing SonarQube, you just need to extract the zip file
$ sudo unzip ~/path/to/sonarqube-8.4.1.35646.zip
(if not installed unzip → $ apt-get install unzip )

To run SonarQube, goto extracted files “sonarqube-8.4.1.35646/bin/linux-x86–64/” and run (This must be done using a non-root user)
$ ./sonar.sh start

To confirm SonarQube, you can also run:
$ ./sonar status
To stop:
$ ./sonar.sh stop

Now go to → http://<your-ip>:9000
and enter default credential admin:admin

--

--