How do you call a rake task from a cap deploy.rb file?

133 views
Skip to first unread message

Wes Gamble

unread,
Jun 3, 2011, 1:24:02 AM6/3/11
to capis...@googlegroups.com
How does one call a rake task from within a deploy task?

I foolishly assumed that cap automatically had access to rake tasks but that doesn't appear to be the case.

Thanks,
Wes

Lee Hambley

unread,
Jun 3, 2011, 3:46:22 AM6/3/11
to capis...@googlegroups.com
Wes, naturally - Cap's DSL was originally styled after rake, it's an easy mistake to make. Depending how you want to do it, you can simply `require` your `Rakefile` in the Cap script, (ensuring of course to include Rake, if that directive is absent from your rakefile), and then you call tasks with something like (and I'm working from memory here)

  Rake::Tasks['mytask'].invoke

(there's also `.execute`, but check the docs for why to use one/the other) - and, check the Rake docs, anyway!

I hope that helps, if not - the easiest alternative, just shell-out and call it that way.

--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

Reply all
Reply to author
Forward
0 new messages