The maze book for programmers!
mazesforprogrammers.com

Algorithms, circle mazes, hex grids, masking, weaving, braiding, 3D and 4D grids, spheres, and more!

DRM-Free Ebook

The Buckblog

assorted ramblings by Jamis Buck

Rake deploy with multiple staging targets

19 October 2006 — 1-minute read

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!

Reader Comments

Super, thx!