Sonar, simple installation on Linux

When I started using Hudson CI Continuous integration server, one of the first things I did was creating a Maven site build. The goal was to do code analysis and get test coverage. I had no knowledge of Sonar, so I did it the oldschool way. Configured surefire, cobertura, findbugs maven checkstyle and added them as plugins in Hudson. Running the site build took about an hour and gave me some decent results.

The problem was that I still felt I was lacking a bit of knowledge about my code. A former colleague of mine suggested Sonar. I did not take long until I realised I couldn’t wait to try it out.

Here is how I installed Sonar on our Debian Linux development box:

cd /tmp
wget http://dist.sonar.codehaus.org/sonar-2.2.zip
mv sonar-2.2.zip /usr/local
unzip sonar-2.2.zip
 
# Create symb link
ln -s sonar-2.2 sonar
 
# I wanted another database then the embedded one
mysql
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all privileges on sonar.* to 'sonar'@'localhost' identified by 'pwd';
flush privileges;
 
# Go to /usr/local/sonar/conf, edit sonar.properties and set database password. 
 
# Run it using your type of linux distro shell : /usr/local/sonar/bin/(distro)
./usr/local/sonar/bin/linux-x86-32/sonar.sh

It’s pretty easy isn’t it?

Of course you have to install the Hudson Sonar plugin

If this setup does not match your desired config, just check out the Sonar site: http://docs.codehaus.org/display/SONAR/Install+Sonar

Sonar dashboard image (Taken from Sonar Nemo)

2 thoughts on “Sonar, simple installation on Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>