Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In my capistrano recipe, I have a namespace with different 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?

like image 894
Tom Avatar asked Aug 11 '11 06:08

Tom


1 Answers

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;
like image 55
Tom Avatar answered Oct 01 '22 22:10

Tom