Capistrano – Adding Help to Deployments

If you don’t do something everyday, you tend to forget how to do it. The same is with the deployments. To help this, you can easily add a help section to Capistrano in your ‘config/deploy.rb’ file. Here is a sample:

desc "Print usage/help information"
task :help do
    puts "Usage: cap <task> -S stage=[staging|production] -S branch=<branch_name>"
    puts ""
    puts "Examples:"
    puts "----------------------------------------------------------------------"
    puts "  Production:"
    puts "    $ cap deploy:migrations -S stage=production"
    puts ""
    puts "  Staging:"
    puts "    $ cap deploy:migrations"
    puts ""
    puts "  Production with branch:"
    puts "    $ cap deploy:migrations -S stage=production -S branch=rel_001"
    puts ""
    puts "  Staging with branch:"
    puts "    $ cap deploy:migrations -S branch=rel_001"
end

When you forget how to do something, just run the following:

$ cap help
 
Usage: cap <task> -S stage=[staging|production] -S branch=<branch_name>
  * executing `help'
Examples:
----------------------------------------------------------------------
  Production:
    $ cap deploy:migrations -S stage=production
 
  Staging:
    $ cap deploy:migrations
 
  Production with branch:
    $ cap deploy:migrations -S stage=production -S branch=rel_001
 
  Staging with branch:
    $ cap deploy:migrations -S branch=rel_001
This entry was posted in Technology and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">