Capistrano 3 : Invoke one custom made task from another task

In previous versions, it was like normal ruby of JavaScript function call

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.

In Capistrano 3 or later

use invoke(), e.g.

desc "Task that does something"
task :do_something do
  invoke 'namespace:task'
end

you also could use Rake::Task["namespace:task"].invoke, this works

Generally you do this by defining dependencies:

before :bar, :foo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s