从一个capistrano任务中调用多级capistrano任务 [英] Calling a multistage capistrano task from within a capistrano task

查看:112
本文介绍了从一个capistrano任务中调用多级capistrano任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个capistrano任务来整合Rails项目的多个阶段的部署。



例如:



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
# b staging
deploy.migrations

production
deploy.migrations
end

这是从另一个帽子任务调用多级任务的正确方法?



构建任务创建一个新的git分支并发布。新分支的名称被保存为capistrano变量。分段和生产阶段任务然后使用此变量指定要部署的分支。



当此任务运行时,它将失败:

 致命:工作树'/ Users /<我的工作目录>'已经存在。 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy/strategy/copy.rb:99:in`initialize':没有这样的文件或目录 - / var / folders / 3d / 3dKYNUwQGOSLZFXsMF-uv ++++ TM / -Tmp- / 20100802182750 / REVISION(Errno :: ENOENT)

我将本地机器的源代码作为git仓库和部署机器无法相互通信。

解决方案

任务名称如

  deploy:production:whatever 

在Cap中显示为

 部署production.whatever 

您还有 top 命名空间去命名空间的顶部,因为这些路径是相对的。



所以,无论你目前的任务是什么命名空间,你总是可以像th

  top.deploy.production.whatever 


I have a capistrano task that consolidates the deployment of multiple stages of a Rails project.

For example:

task :consolidated_task do
    build #creates a new release branch from master, 
          #sets a variable with the relese branch name

    staging
    deploy.migrations

    production
    deploy.migrations
end

Is this the proper way to call a multistage task from another cap task?

The build task creates a new git branch and published it. The name of the new branch gets saved as a capistrano variable. the staging and production stage tasks then use this variable to specify what branch to deploy from.

When this task runs, it fails with:

fatal: working tree '/Users/<my working directory>' already exists.
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy/strategy/copy.rb:99:in `initialize': No such file or directory - /var/folders/3d/3dKYNUwQGOSLZFXsMF-uv++++TM/-Tmp-/20100802182750/REVISION (Errno::ENOENT)

I'm pushing the source from my local machine as the git repository and the deployment machine cannot communicate with each other.

解决方案

Task names like

deploy:production:whatever

are exposed within Cap as

deploy.production.whatever

You also have top namespaces to go to the top of the namespaces, because the paths are relative.

So, no matter in which namespace your task currently is you can always do thigs like:

top.deploy.production.whatever

这篇关于从一个capistrano任务中调用多级capistrano任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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