Rake deploy with multiple staging targets

Posted by Jamis on October 19, 2006 @ 09:35 AM

Jeroen Houben posted a nifty technique on the Capistrano mailing list this morning. He was wanting a way to do:


$ rake remote:staging:deploy

Basically, he wanted to be able to specify which stage should be the target of an arbitrary capistrano task. I suggested that he could use the cap command directly, with the -f switch to specify a different recipe file:


$ cap -f config/deploy.staging.rb deploy

However, Jeroen pointed out that he liked being able to do rake -T to see all the possible deployment commands. He wanted to be able to see all the various staging options there, too. So, he dug in and came up with a way to easily copy the existing remote:xyz tasks into a subnamespace. His solution makes it as easy to do as:

1
2
3
4
5
6
7
8
9
namespace :remote do

  # remote:staging:deploy, remote:staging:migrate, etc.
  copy_remote_tasks("staging")

  # remote:network_dev:deploy, remote:network_dev:migrate, etc.
  copy_remote_tasks("network_dev")

end

Great work, Jeroen!

Posted in Tips & Tricks

Comments

Have something to add? Click here to leave a comment.

20 Oct 2006

1. Eepea said...

Super, thx!