Capistrano deploy tag, using wrong revision


You have your code under SVN, and trying to deploy via Capistrano. You capify your root folder, you cap deploy:setup, everything works. How do you deploy a specific tag?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
set :application, "my-app"
set :repository_root,  "https://my.svn.com/code/myapp"
 
set :scm, :subversion
set :scm_username, "username"
set :scm_password, "password"
 
 
######
#Here we ask deployer which svn tag to use
######
set(:tag) { Capistrano::CLI.ui.ask("Tag to use for deployment  ") }
set(:repository) { (tag == "trunk") ? "#{repository_root}/trunk" : "#{repository_root}/tags/#{tag}" }
set :deploy_via, :export
 
# Make capistrano write the proper revision 
# into the REVISION file.
require 'capistrano/recipes/deploy/scm/subversion'    
Capistrano::Deploy::SCM::Subversion.class_eval do
  def query_revision(revision)
    return revision if revision =~ /^\d+$/
    result = yield(scm(:info, repository, authentication, "-r#{revision}"))
    YAML.load(result)['Last Changed Rev']
  end
end
 
# Some more config
set :domain,    'my.domain.com'
set :deploy_to,   '/home/codingfolder/codesource/myapp'  #this is where the folder structure for current, releases, shared will be. this path should not be under www.  www can link to 'current'
set :deploy_via,  :export
 
#Your HTTP server, Apache/etc
set :user,        'codingfolder'                      #this is the ssh user
role :web,        'server1.com','server2.com'
role :app,        'server1.com','server2.com'                         
 
set  :use_sudo,   false
set  :keep_releases,   5