Jenkins integration with Sonarqube

Go to the Jenkins dashboard at localhost:8080 Click on the new item option

image.png

Enter the name for the project Select project type as maven project Click on OK

image.png

In the dashboard that appears, go the source code management and provide the location of the github repository that hold the Jenkinsfile for the maven command invocation.

image.png

Provide the complete path of the pom.xml file. If it lies inside a folder use {folder_name}/pom.xml

image.png

The Jenkinsfile for the project must contain a stage that defines the following command: mvn sonar:sonar -Dsonar.host.url=localhost:9000 -Dsonar.analysis.mode=publish

image.png

The project should lead you to a dashboard similar to this. Click on the build now option Click the option of console output to check the build process

image.png

The build starts to happen If the build becomes successful, then it would reflect “BUILD SUCCESS” and give the location (as a URL) where the code report is published. As in this case it shows it is available at: localhost:9000/dashboard?id=Sonar_Test%3ASo..

image.png

Visiting the above given URL, it shows the report for the code compiled and published.

image.png