Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonar integration with SVN

I am using SVN as a version management tool for my project, and am planning to use sonar for project analysis.

How do I make sonar project analysis run every time code is checked into SVN?

like image 884
samarth Avatar asked Aug 04 '11 14:08

samarth


1 Answers

Do not do complex stuff as a pre-commit hook! When a user does a commit, control does not return to the user until after the pre-commit hook has completed. Since Sonar has to compile your code, your users will have to wait on every commit for the following:

  • Checking out the code
  • Compiling the code
  • Running all of the tests and checks that Sonar performs
  • Waiting for Sonar to complete its reporting and updating its database

How long will all of this take? 10 minutes? 20 minutes? 5 minutes? Let's assume that your code is small or your compiler is very fast, so it takes a mere 4 minutes. Do your users want to wait 4 minutes each and every time they perform a commit in order to start their work again?

Instead, get a continuous build server like Jenkins. Jenkins is fast and simple to setup. It's a simple *.war file. You simply run:

$ java -jar jenkins.war

And, you're up and running. Once Hudson is up, you define a "job". Just enter in the required information, and save. Every time, someone does a commit in Subversion, Hudson will build in the background.

Where all the fun comes in are the dozens (and maybe hundreds) of third party plugins that can extend Jenkins. For example, there's a Sonar plugin that will run your Sonar tasks, update your database, and produce some nice looking reports.

If there are problems, Jenkins will email the person responsible and the entire development team. (Plugins allow Jenkins to IM, Tweet, and even change a stoplight from green to red). This immediate feedback and public knowledge will get your developers to do their own tests before doing a commit.

like image 182
David W. Avatar answered Sep 17 '22 15:09

David W.