在我的capistrano配方中,我有一个执行不同任务的 namespace :

namespace :mystuff do
  task :mysetup do; ... end;
  task :mytask1 do; ... end;
  task :mytask2 do; ... end;
  task :mycleanup do; ... end;
end

These customised tasks are triggered via lines like this at the top of my recipe:

after "deploy", "mystuff:mycleanup"

我想从我的 namespace 中执行常规的capistrano任务。例如,如果已经建立了一定数量的发布文件夹,我想自动触发正常的清理任务:
task :mycleanup do;
  if releases.length > 50
    logger.info "Too many releases, runing deploy:cleanup."
    deploy:cleanup #***THIS DOESN'T WORK***
  end
end;

不幸的是,从我的 namespace 内部调用deploy:cleanup无效。如何执行deploy:cleanup

最佳答案

啊哈,正确的语法是使用.,而不是:。即deploy.cleanup,没有deploy:cleanup

这有效:

task :mycleanup do;
  if releases.length > 50
    logger.info "Too many releases, runing deploy:cleanup."
    deploy.cleanup
  end
end;

关于ruby - 如何从不同于:deploy?的命名空间触发Capistrano任务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7021523/

10-13 08:41