在我的 Capistrano 配方中,我有一个具有不同任务的命名空间:
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"
我想从我的命名空间中执行一个普通的 capistrano 任务。例如,如果已经建立了一定数量的发布文件夹,我想自动触发正常的清理任务:
task :mycleanup do;
if releases.length > 50
logger.info "Too many releases, runing deploy:cleanup."
deploy:cleanup #***THIS DOESN'T WORK***
end
end;
不幸的是,在我的命名空间内调用 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/