Deploying a Subversion branch with Capistrano

Capistrano is a tool for automating tasks via SSH on remote servers. It has many uses, I (and many others) use it to deploy their (rails) applications. The best I can tell there is no built in way to deploy a branch from your source code control system. There are a couple ways of accomplishing this. I chose passing in the branch as a parameter to the Capistrano command:

cap --set-before branch=testbranch  deploy

…where ‘testbranch’ is the name of my subversion branch, and ‘deploy’ is the action to take. The ‘–set-before option’ sets a variable before the recipes are loaded (sort of). All you need to do to make this work you just need to set the repository URL correctly based on if the branch variable exists or not. In my case, that is editing the top of deploy.rb in the config section of my rails app:

if variables.include?(:branch)
  set :repository,  "http://svn.example.com/project/branches/#{branch}"
else
  set :repository,  "http://svn.example.com/project/trunk"
end

http://www.missiondata.com/blog/system-administration/84/deploying-an-svn-branch-with-capistrano/