从capistrano任务中调用多级capistrano任务

man*_*ode 4 deployment capistrano ruby-on-rails

我有一个capistrano任务,它整合了Rails项目的多个阶段的部署.

例如:

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
Run Code Online (Sandbox Code Playgroud)

这是从另一个上限任务调用多阶段任务的正确方法吗?

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

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

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)
Run Code Online (Sandbox Code Playgroud)

我正在从我的本地机器推送源代码作为git存储库,并且部署机器无法相互通信.

emz*_*ero 7

任务名称如

deploy:production:whatever
Run Code Online (Sandbox Code Playgroud)

在Cap中暴露

deploy.production.whatever
Run Code Online (Sandbox Code Playgroud)

您还可以使用top命名空间转到命名空间的顶部,因为路径是相对的.

因此,无论您的任务目前在哪个命名空间,您都可以像以下一样:

top.deploy.production.whatever
Run Code Online (Sandbox Code Playgroud)