Rails 中的自动化部署

发布于 2024-07-28 22:34:26 字数 1103 浏览 7 评论 0原文

我正在开发我的第一个 Rails 应用程序,并正在努力寻找一种高效且干净的解决方案来进行自动结账和部署。

到目前为止,我已经查看了 CruiseControl.rb (熟悉 CruiseControl.NET)和 Capistrano。 不幸的是,除非我错过了什么,否则他们每个人只做了我想要的大约一半(每个人都做了不同的一半)。

到目前为止我所看到的:

CruiseControl 的

  • 优势
    • 提交后在存储库签出的基础上自动构建
    • 还运行单元/功能测试并返回报告
  • 弱点
    • 没有内置部署机制(到目前为止我能找到的最好方法是编写自己的 bash 脚本)

Capistrano 的

  • 优势
    • 专为部署而打造
  • 缺点
    • 必须通过命令启动(即提交时不进行自动签出)

我找到了将两者串在一起的方法 - 即让 CruiseControl ping 存储库以进行更改,在提交时进行签出提交、运行测试等,然后在完成部署后调用 Capistrano(尽管 Capistrano 也将进行存储库签出)。

基本上,当一切都说了又做了之后,我想设置三个项目:

  • 开发:签出/部署完全没有接触。 当有人提交文件时,会进行检查、运行测试、部署更改并报告回来
  • 阶段:签出/部署需要单击按钮
  • 生产:单击按钮会执行标记签出或从阶段移动文件

我有这个在 .NET 世界中结合使用 CruiseControl.NET 和 MSBuild,这相当简单。 我猜这也是 ruby​​ 部署世界中的常见模式,但我很容易出错。

I'm working on my first rails app and am struggling trying to find an efficient and clean solution for doing automated checkouts and deployments.

So far I've looked at both CruiseControl.rb (having been familiar with CruiseControl.NET) and Capistrano. Unfortunately, unless I'm missing something, each one of them only does about half of what I want (with each one doing a different half).

For what I've seen so far:

CruiseControl

  • Strengths
    • Automated builds on repository checkouts upon commit
    • Also runs unit/functional tests and reports back
  • Weaknesses
    • No built-in deployment mechanisms (best I can find so far is writing your own bash scripts)

Capistrano

  • Strengths
    • Built for deployments
  • Weaknesses
    • Has to be kicked off via a command (i.e. doesn't do automated checkouts upon commit)

I've found ways that I can string the two together -- i.e. have CruiseControl ping the repository for changes, do a checkout upon commit, run the tests, etc. and then make a call to Capistrano when finished to do the deployment (even though Capistrano is also going to do a repository checkout).

Basically, when all is said and done, I'd like to have three projects set up:

  • Dev: Checkout/Deployment is entirely no touch. When someone commits a file, something checks it out, runs the tests, deploys the changes, and reports back
  • Stage: Checkout/Deployment requires a button click
  • Prod: Button click does either a tagged check out or moves the files from stage

I have this working with a combination of CruiseControl.NET and MSBuild in the .NET world, and it was fairly straightforward. I would guess this is also a common pattern in the ruby deployment world, but I could easily be mistaken.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

£噩梦荏苒 2024-08-04 22:34:26

我会尝试Hudson(免费且开源)。 我开始使用 CruiseControl,但厌倦了每次需要更改设置或添加项目时都必须重新学习 XML 配置。 然后我开始使用 Hudson,并且再也没有回头。 Hudson 或多或少可以通过网络进行完全配置。 它最初是 Java 的持续集成工具,但具有用于其他开发堆栈的插件例如 .NET 和 Ruby on Rails。 有一个 Rake 插件。 如果这不起作用,您可以将其配置为在运行 Rake 构建/测试后执行任何任意命令行。

我还应该补充一点,让 Hudson 运行起来非常容易:

java -jar hudson.war

或者您可以将 war 放入任何 servlet 容器中。

I would give Hudson a try (free and open source). I started off using CruiseControl but got sick of having to relearn the XML configuration every time I needed to change a setting or add a project. Then I started using Hudson and never looked back. Hudson is more or less completely configurable over the web. It was initially a continuous integration tool for Java but has plugins for other development stack such as .NET and Ruby on Rails. There's a Rake plugin. If that doesn't work, you can configure it to execute any arbitrary command line after running your Rake builds/tests.

I should also add it's extremely easy to get Hudson going:

java -jar hudson.war

Or you can drop the war in any servlet container.

如此安好 2024-08-04 22:34:26

无论如何,我会使用两个系统来构建和部署。 至少有两个原因:您应该能够单独运行它,并且您应该有两个配置文件,一个用于部署,一个用于构建。 但您可以轻松地将这两个系统粘合在一起。

只需创建一个简单的 capistrano 任务,即可进行测试并向您报告。 您可以使用“运行”命令执行任何您想要的操作。

如果你不需要任何命令行工具,两年前就有 webistrano。

可以使用类似 http://github.com/benschwarz/gitnotify/tree/master 如果您使用 git 作为存储库,则触发构建部署。

I would use two system to build and deploy anyway. At least two reasons: you should be able to run it separately and you should have two config files one for deploy and one for build. But you can easily glue the two systems together.

Just create a simple capistrano task, that tests and reports back to you. You can use the "run" command to do anything you want.

If you don't want any command line tool there was webistrano 2 years ago.

To could use something like http://github.com/benschwarz/gitnotify/tree/master to trigger the build deploy if you use git as repository.

笔芯 2024-08-04 22:34:26

至少对于开发自动化部署,请查看 git 中可用的挂钩脚本:

http://git-scm。 com/docs/githooks

我认为您需要关注 post-receive 挂钩脚本,因为它在推送到远程服务器后运行。

还值得查看 github 上 Mislav 的 git-deploy。 使管理部署变得非常干净。

http://github.com/mislav/git-deploy

At least for development automated deployments, check out the hook scripts available in git:

http://git-scm.com/docs/githooks

I think you'll want to focus on the post-receive hook script, since this runs after a push to a remote server.

Also worth checking out Mislav's git-deploy on github. Makes managing deployments pretty clean.

http://github.com/mislav/git-deploy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文