Run Sonar Runner on each SVN commit to analyze the results of SVN files

I have installed SonarQube on my ubuntu machine and run the sonar runner for one of my PHP projects. It works fine and I can see all errors in the sonar panel.

http://localhost:9000/sonar

      

But I really want to parse all files for errors to be committed in my svn repository. I've read a lot about Hudson and Jenkins but don't really get the exact idea. My previous company had both sonar and svn. When we were uploading files to svn, sonar used to parse the codes of all outgoing files, and my svn client returned the entire error.

I also read about pre and post commit svn hooks, but experts say it will take a long time to commit a file and other users will wait for them to use svn.

Can anyone help me to solve this problem.

+3


source to share


1 answer


Assuming you have access to the svn repository server, an automatic build system (maven / ant or similar), and the sonar server has an extension plugin built in with quality settings, you can write a simple shell script to:

  • Svn update repository workspace
  • compile the task (maven / ant)
  • perform a sonar runner in incremental mode
  • custom error messages when breaking assembly


Copy the script to the repository hook directory. If the repository already has a pre-commit hook, add the command / bin / sh your_shell_script_full_path.

If the pre-commit file does not exist, create a pre-commit.sh file and include it.

0


source







All Articles