Skip to content

Latest commit

 

History

History
34 lines (20 loc) · 1.63 KB

2.x-DSL-Configuration-Tasks-After.md

File metadata and controls

34 lines (20 loc) · 1.63 KB

Definition

after(task_name, *args, &block) 

Module

Capistrano::Configuration::Callbacks 

This method lets you tell Capistrano to invoke one or more other tasks after invoking a particular task. This makes it very easy to extend an existing recipe, by adding these hooks to be executed after some task. (For adding tasks to be executed before another task, see the before method.)

Arguments

task_name

This may be either a symbol or a string that gives the fully qualified name of the task to extend. This means that if you want to extend the deploy:upload task, you must give the task name as deploy:upload, and not merely as :upload.

The task does not have to exist at the time the callback is defined. If it does not exist, it will never be called, and the callback will never be used. If it is defined later, the callback defined by after will be remembered.

*args

This must be zero or task arguments, identifying the tasks that should be executed after task_name is executed. Multiple invocations of after will imply the order in which the callbacks are invoked.

after "deploy:symlink", :symlink_database_config
after "deploy:symlink", "uname", "-a"

&block

If a block is given, it will be treated as an anonymous task. The block itself will be invoked after task_name, and will use the same server scope as task_name. In general, using a block with after is discouraged because it makes it harder to reuse code, but there are times when it can be genuinely useful.

after "deploy:symlink" do
  run "#{sudo} ln -nsf /path/to/real/config.yml /u/apps/social/current/config/database.yml"
end