1. install JDK
sudo apt-get install default-jdk
2. Download the package on http://www.sonarqube.org/downloads/
unzip sonarqube-[version].zip
3. Change the config for Postgresql
vim sonar/conf/sonar.properties
change the username and password for progresql like this:
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://[ip:localhost if your db at same server]/sonar
4. If the jdk is installed, uncommet this line under in sonar/conf/wrapper.conf
wrapper.java.additional.6=-server
5. Set up for Postgresql Server:
sudo su postgres
createuser sonar -P
enter password: sonar
nnn
psql
create database sonar with owner sonar encoding ‘utf8’;
/q
6. If the Postgresql Server isn't on localhost, add a line for verification in pg_hba.conf
sudo vim /etc/postgresql/9.1/main/pg_hba.conf
host all sonar 192.168.1.0/24 md5
7. Test to connect db server
sudo apt-get install postgresql-client
psql -d sonar -h [ip of db server] -U sonar
8. Start Sonar:
sudo sonar/bin/[linux-x86-64]/sonar.sh start
9. Register as a service:
sudo vim /etc/init.d/sonar
#! /bin/sh
/home/admin01/sonar4/bin/linux-x86-64/sonar.sh $*
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults
sudo service sonar start
10. maven config:
vim ~/.m2/setting.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.jdbc.url>jdbc:postgresql://[ip]/sonar</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://[ip]:9000</sonar.host.url>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sonar</activeProfile>
</activeProfiles>
</settings>
11. Push your project to Sonar
Add maven plugin:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.2</version>
</plugin>
Run this:
mvn sonar:sonar