Jenkins With SonarQube#
Introduction#
- In this section, we will try to integrate 
SonarQubeintoJenkins pipelinefor checking the quality of Spring Boot project when there are new commits. - If you have not known about Jenkins, SonarQube or how to integrate your Spring Boot project with SonarQube. I will recommend read posts below:
 
SonarQube Configuration#
- Firstly, you should access 
Sonarqube server. Then go toAdministration-->Security-->Permission Templateand check the checkbox forExecute Analysisfor yourSonarqubeaccount that you will use on Jenkins. - So for this configuration, the user will have permission to execute sonar analysis when we use this user on Jenkins Server.
 
- Next you go to 
My Account-->Securityand generate aTokenas below. So this Token will be used for accessing SonarQube Server instead of using username/password. 
- You can try this token by replacing the 
username/passwordinpom.xmlof your Spring Boot project. 
| pom.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  |  | 
- Next, you should go to 
Administration->Configuration->WebHooksand clickCreatebutton. Then add some information asNameandURL. - Note: the 
URLhas format like{JENKINS SERVER}/sonarqube-webhook/. For exmaple: your Jenkins Server is running athttp://192.168.1.18:8081so theURLshould behttp://192.168.1.18:8081/sonarqube-webhook/. - Note: On Jenkins Server we have to add plugin 
Sonarqube Scannerwhich will do in the StepJENKINS CONFIGURATIONbelow, then theURLabove will be available. 
Jenkins Configuration#
- First, let’s go to 
Manage Jenkins->Manage Plugins-> Then choose tagAvailableand findSonarQube Scanner-> then clickInstall 
- Next, go to the 
Manage Jenkins->Global Tool Configuration-> scroll down to tagSonarQube Scannerand fill some information as below: 
- Next, go to 
Manage Jenkins->Configure System-> scroll down to tagSonarQube serversand fill some information asName,URL of sonarqube server. 
- Then at step 
Server authentication token, let's choose buttonAddto add theSonarQube Token 
- Let's choose 
Secret Text, put yourSonarQube Token, add a description and clickaddbutton. 
- Now, at step 
Server authentication tokenyou can choose yourSonarQube Tokenas the image below. 
- Finally, let's create/update your 
Jenkinsfilein your project as below. 
| build.Jenkinsfile | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  |  | 
Testing#
- Finally, commit and push the 
Jenkinfilein your repository then go to Jenkins server to check the build result. 
- So, that’s it. Thanks and Good luck!
 











