Thursday, March 27, 2014

Install Sonar on Ubuntu 12.04 with Postgresql

1. install JDK
sudo apt-get install default-jdk

2. Download the package on
unzip sonarqube-[version].zip

3. Change the config for Postgresql
vim sonar/conf/
change the username and password for progresql like this:
  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

5. Set up for Postgresql Server:
sudo su postgres
createuser sonar -P
  enter password: sonar

  create database sonar with owner sonar encoding ‘utf8’;
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             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]/ start

9. Register as a service:
sudo vim /etc/init.d/sonar
     #! /bin/sh
     /home/admin01/sonar4/bin/linux-x86-64/ $*

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="" xmlns:xsi="" xsi:schemaLocation="">

11. Push your project to Sonar
Add maven plugin:

Run this:
mvn sonar:sonar