Search code examples
ruby-on-railscapistrano

How do I invoke one Capistrano task from another?


How do I invoke one Capistrano task from another?

For example:

task :foo do
  # stuff
end

task :bar do
  # INVOKE :foo
end

Solution

  • You can do it by using namespace:

    namespace :test do
      task :one do
      end
      task :two do
        test.one
        #or just directly call it:
        one
      end
    end
    

    Just be careful with the name you use to not overwrite some important function.