开发者

How can I trigger a Capistrano task from a different namespace than :deploy?

开发者 https://www.devze.com 2023-03-27 20:52 出处:网络
In my capistrano recipe, I have a namespace with diff开发者_如何学Goerent tasks: namespace :mystuff do

In my capistrano recipe, I have a namespace with diff开发者_如何学Goerent tasks:

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"

I want to execute a normal capistrano task from inside my namespace. For example, I want to automatically trigger the normal cleanup task if a certain number of release folders have built up:

task :mycleanup do;
  if releases.length > 50
    logger.info "Too many releases, runing deploy:cleanup."
    deploy:cleanup #***THIS DOESN'T WORK***
  end
end;

Unfortunately calling deploy:cleanup doesn't work from inside my namespace. How can I execute deploy:cleanup?


Aha, the correct syntax is to use a ., not a :. i.e. deploy.cleanup, no deploy:cleanup.

This works:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号