
Introduction
SonarQube is a free and open source code quality measuring and management tool which is developed using java and maintained by sonarsource. It can analyze source code in 20+ different languages. Input can be the project source code or compiled code depending on the language.
Install SonarQube 5.6.6 (LTS *)
1 2 3 4 |
cd /home wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.6.zip unzip sonarqube-5.6.6.zip sudo mv sonarqube-5.6.6 /etc/sonarqube |
Start sonarQube
1 2 |
cd /etc/sonarqube/bin/linux-x86-64 ./sonar.sh start |
Install maven
Run this command to install the latest Apache Maven.
1 |
sudo apt-get install maven |
Ensure that you successfully installed maven on your machine
1 2 3 4 5 6 |
mvn -version Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-75-generic", arch: "amd64", family: "unix" |
Configure sonarQube with maven
Open settings.xml maven config
1 2 |
cd /usr/share/maven sudo vi settings.xml |
Go to pluginGroups tag and add
1 |
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup> |
Go to profiles tag and add
1 2 3 4 5 6 7 8 9 10 |
<profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.host.url>http://localhost:9000 </sonar.host.url> </properties> </profile> |
SonarQube plugin in Jenkins
Install SonarQube in Jenkins
Login to Jenkins dashboard and navigate to Manage Jenkins >> Manage Plugins >> Available Tab and select “SonarQube Scanner for Jenkins” plugin and install.
Configure sonarQube with Jenkins
Add MAVEN_HOME in Jenkins
Go to Manage Jenkins >>cofiguring the system, Search SonarQube servers section, Check “Enable injection of SonarQube server” and click “Add a SonarQube installation” button
In the build configuration go to Actions following the build section and click “Add an action after the build” button and choose “SonarQube analysis with Maven”
bad Jokes
Thank you for sharing your thoughts. I truly appreciate your efforts and I am waiting for your
further write ups thank you once again.
saravanan
hi,
Thanks for your information. I have separate slave nodes for jenkins and i want to sonar analysis from slave nodes. I have installed sonarqube on separate machine. how do i configure the pipeline script to run sonarqube remotely from master
cynda
hi,
Thanks for your information
Arnulfo Reilley
Just fabulous. Who wrote this and how can we get more?