Calling a multistage capistrano task from within a

2019-05-07 01:39发布

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.

1条回答
混吃等死
2楼-- · 2019-05-07 01:58

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
查看更多
登录 后发表回答