Installation of SonarQube + Jenkins | CodeUsingJava

We'll look at how to integrate sonar cube report with the Jenkins in this session

In previous tutorial we have seen how to integrate sonar scanner with maven. We will automate the same process here using the Jenkins.
In this tutorial we will need version control tool. I will be using git and github. I will create a centralized repository using the github where all the developers are going to check in their code and Jenkin will take that code and scan it using sonar scanner plus it is going to publish the report.
Now let us have look at how to install jenkins: First go to site "" I have downloaded following verion


Extract the zip and start the installation.


It will show the destination folder for installation.


Click on install to start the installation.


Wait till the installation is finished


Once installation in over click finish button.


It will automatically open "localhost:8080/login" in browser after clicking on finish button. Go to the path specified in above image, copy the password and click on continue


It will ask you what kind of installation you need. I have choosen "install suggested plugins". You can select plugins also which are required to you.


It will take some time to install the plugins.


Following plugins will be installed.


It will ask to create a user fill the details or you can even continue as admin.


You can also change the port number here. or skip this step.


Now Jenkins is ready to user


This will be your dashboard


If you use github as a version control, please make sure you have the following settings on your Jenkins Go to Manage Jenkins


Go to global tool configuration. Here you will have section for git.


Here you need to give path to the executable. Wherever you have installed the git in your local machine give the path here. Click on save.


Next is, If you want to be notified about the build is success or failure of the report by email. Go to Configure System


Scroll down to last, you will see section for E-mail Notification


Here you need to fill the details required. You can even test from this section if the email notification is successfull or not by clicking on test configuration. Before that you need to fill all the details.


Now we will create a new job. Click on New Item. Below window will open. Enter the item name


Select Freestyle project and click Ok


We need to execute the project which is deployed on the github. I already have previous tutorails maven project on github


In general you need to enter git project url


Now go to source code management tab below. Here we will be using git. Select git You need to give the repository url and credentials to access that url.


To add credentials you need to click on add.


It will open below window. Give your username and password for the github accout. Click add.


Next is Build Triggers. Build can be specified in different ways. Even manually you can build. From the following options you can select when you have to build like build periodically or even when new changes are pushed then also it can build. Based on your requirements you can select these things.


Next part is Build Environment. Here also there are different options you can select for example delete workspace before build starts or abort build if it's stuck


Next is Build. How you are going to build your project. Here what you can do select the option from below.


I have selected execute on window batch command. Here I am specifying "mvn clean sonar:sonar". Our project already have the sonar maven plugin. So sonar scanner will automatically nalyze the code and publish the report. Instead of running manually from the command line now, we're going to automate this process with the Jenkins


Last is Post-Build Actions. You can enable it here if you wish to receive an email notification about the build. Here there are various options like publish JUnit Reports, send build status on git etc. Click on Save.


Before you build you need to start the SonarQube server "StartSonar.bat"


After the sonarqube is started click on Build Now. It will run the commad we have provided.


After build is complete it will show like below screen. Click on #1


It will show below window.


Click on Console Output, it will give all the details. Scroll till last there will be a sonar qube link click on it.


It will open below screen


Hope you understand the concept of how to integrate the sonarqube scanner with the Jenkins and how to automate the construction process