Installing Sonar on the CI server
I’ve been trying out Sonar and it looks great – it’s much more presentable than trawling through maven sites to find build reports. Anyway, I decided to install it on the live build server today, and this is how it happened:
What you’ll need:
Maven
Java JDK
Download Sonar from http://www.sonarsource.org/downloads/
Copy the zip archive over to the build server. I unzipped it in /home/maven/sonar
I’m running a linux x86 32 bit system, so to start Sonar, I cd to:
/home/maven/sonar/sonar-2.5/bin/linux-x86-32
and run:
./sonar.sh start
Sometimes it can take a few minutes for the server to start up, so be patient. Eventually you’ll find your Sonar site up and running at http://{SERVERNAME}:9000 (where {SERVERNAME} is the name of your build server where you installed Sonar. It should look a bit like this:
Next, you have to configure Maven. I’m running with the default
Apache Derby database which ships with Sonar, so I added the following
section to my maven settings.xml (which I found under
/home/maven/maven-2.0.9/conf). You need to add this to the
<profiles> section:
<profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.jdbc.url> jdbc:derby://localhost:1527/sonar;create=true </sonar.jdbc.url> <sonar.jdbc.driver>org.apache.derby.jdbc.ClientDriver</sonar.jdbc.driver> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> <sonar.host.url>http://localhost:9000</sonar.host.url> </properties> </profile>
Then you will need to run your first project against sonar! Go to the root of one of your projects on the build server (for me they were in /home/maven/Bamboo/xml-data/build-dir/PROJ_NAME) and run:
mvn clean install sonar:sonar
Go to http://{SERVERNAME}:9000 and you should now see your project listed. Click on it and revel in sonar goodness:
I'll migrate to a MySQL db next week, and put an update here about what to do.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)







