使用capistrano部署一次特定分支吗? [英] Deploy once a specific branch with capistrano?

查看:85
本文介绍了使用capistrano部署一次特定分支吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个非常简单的分支策略:

We have a very simple branching strategy:


  • develop->开发分支

  • 登台->分段服务器部署分支

  • 主-> Productio分支

我们的生产部署工作流程是开发->分期->掌握。我们总是先部署到暂存阶段,测试一段时间,然后再部署到生产环境。

Our production deploy workflow is develop -> staging -> master. We always deploy first to staging, we test for some time, and then we deploy to production.

现在,我们正在开发一项我想测试的新功能。我不想将其放到舞台上,因为出于试验目的,在功能完成之前,我不希望锁定生产部署。

Right now we're working in a new feature that I would like to test. I don't want to put it in staging because, since is experimental, I would not like to lock a production deploy until the feature is finished.

是否有一种方法可以对需要进行特定部署的分支capistrano说,所以我可以将此实验代码分阶段进行测试?

Is there a way to say to capistrano the branch I want for one particular deploy, so I could put this experimental code in staging to test it?

OBS:我需要进行登台的原因是,这段代码取决于许多已经在登台中配置的外部资源,因此很难复制当地。

OBS: The reason I need to put in staging is that this piece of code depends on a lot of external resources that are already configured in staging and would be difficult to replicate locally.

推荐答案

这就是我的方法。

我的 config / deploy / staging.rb 文件中,我输入了以下内容:

At the top of my config/deploy/staging.rb file, I put this:

set :branch, ENV.fetch("CAPISTRANO_BRANCH", "staging")

这告诉Capistrano当我运行 cap临时部署时,默认情况下使用 staging 分支,但允许使用<$覆盖该分支c $ c> CAPISTRANO_BRANCH 环境变量。

This tells Capistrano that when I run cap staging deploy, use the staging branch by default, but allow that to be overridden by the CAPISTRANO_BRANCH environment variable.

因此,现在,如果我想将自定义分支部署到暂存环境,就这么简单:

So now if I want to deploy a custom branch to staging, it is as simple as this:

CAPISTRANO_BRANCH=my-feature cap staging deploy

这篇关于使用capistrano部署一次特定分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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