声纳与SVN集成 [英] Sonar integration with SVN
问题描述
我正在将SVN用作项目的版本管理工具,并计划使用声纳进行项目分析.
I am using SVN as a version management tool for my project, and am planning to use sonar for project analysis.
每次将代码检入SVN时如何运行声纳项目分析?
How do I make sonar project analysis run every time code is checked into SVN?
推荐答案
请勿将复杂的内容作为预提交的钩子!当用户进行提交时,直到预提交挂钩完成后,控制权才返回给用户.由于Sonar必须编译您的代码,因此您的用户将不得不在每次提交时等待以下内容:
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:
- 签出代码
- 编译代码
- 运行所有测试并检查Sonar的执行情况
- 等待Sonar完成报告并更新其数据库
这一切需要多长时间? 10分钟? 20分钟? 5分钟?假设您的代码很小或编译器非常快,那么仅需4分钟.您的用户是否希望每次执行一次提交都等待4分钟才能重新开始工作?
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?
相反,获得一个连续的构建服务器,例如 Jenkins . Jenkins快速且易于设置.这是一个简单的* .war文件.您只需运行:
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
然后,您就可以运行了.哈德森(Hudson)建立起来后,就可以定义一个职位".只需输入所需信息,然后保存.每当有人在Subversion中进行提交时,Hudson就会在后台进行构建.
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.
所有乐趣都来自可以扩展Jenkins的数十个(也许数百个)第三方插件.例如,有一个Sonar插件,它将运行您的Sonar任务,更新数据库并生成一些美观的报告.
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.
如果有问题,Jenkins将向负责人和整个开发团队发送电子邮件. (插件允许Jenkins进行IM,Tweet甚至将信号灯从绿色更改为红色).这种即时反馈和公共知识将使您的开发人员在进行提交之前先进行自己的测试.
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.
这篇关于声纳与SVN集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!