Capistrano – Deploying a Branch

When deploying from Capistrano, I like to have the following in my ‘deploy.rb’ file:

set :scm, "git"
set :repository, "git@www.example.com:project.git"
set :git_shallow_clone, 1
set :deploy_via, :remote_cache

This allows speeds deployments by keeping a versions checked out on the server in ‘shared/cached-copy’. When it comes to deploying, it is always best to deploy from a branch instead of the master/head/trunk. To handle this, add the following:

set :branch, fetch(:branch, “master”)

When you deploy, run the following:

$ cap deploy -S branch=REL_1.0

If you don’t specify the branch, the master is used.

This entry was posted in Technology and tagged , , , , . Bookmark the permalink.

2 Responses to Capistrano – Deploying a Branch

  1. Lee Hambley says:

    Can I suggest this improvement:

    set :branch, fetch(:branch, “master”)

    fetch returns it’s 2nd argument if the 1st (the varaible name) is nil, otherwise it returns the preexisting value

  2. Darian Shimy says:

    Lee, thanks for the tip! Code has been updated.

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="">