声纳与 SVN 的集成 [英] Sonar integration with SVN

查看:19
本文介绍了声纳与 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 发送即时消息、发推文,甚至可以将红绿灯从绿色变为红色).这种即时反馈和公共知识将使您的开发人员在提交之前进行自己的测试.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆