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?
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?
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:
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:
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.
You could investigate Hudson. There is a Sonar plugin for it.