1
votes

I have a short multistage capistrano script that specifies a default stage (set :default_stage, :staging), but I find that when I specify another stage on the command line (e.g. cap production deploy), both the staging and production tasks are run:

$ cap production deploy
    triggering load callbacks
  * 2013-06-19 06:38:34 executing `staging'
  * 2013-06-19 06:38:34 executing `production'

As a consequence, the deployment process looks for the scm in the location specified by staging.rb, which is a local repository -- so it doesn't exist for the production server, and my deployment fails.

Can I provide a default stage in my deploy script but not have it loaded when I specify another stage on the command line?


You can see my deploy files here:

deploy.rb

set :stages, [:staging, :production]
set :default_stage, :staging
require 'capistrano/ext/multistage'

set :repository,  "myrepo"
set :scm, :git
set :scm_user, "deploy"

set :user, "deploy"
set (:deploy_to) {"/var/www/clu2/#{application}/"}
set :use_sudo, false
default_run_options[:pty] = true

production.rb

set :application, "production"
set :rails_env, 'production'
set :deploy_to, "/var/www/myapp/"
set :branch, 'develop'

role :app, 'trustedquote.com'
role :web, 'trustedquote.com'
role :db, 'trustedquote.com', :primary => true

staging.rb

set :application, "staging"
set :rails_env, 'production'
set :repository,  "file:///git/myrepo.git"
set :local_repository, "file://."

set :branch, 'develop'

role :app, 'mylocation'
role :web, 'mylocation'
role :db, 'mylocation', :primary => true
1
To answer your original question, yes, you can. Your examples above look a bit different than github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension ... - CDub
Wow. The change I made was to use strings instead of symbols to designate my stages, and that appears to have made the difference I needed. Thanks, @CDub. - JellicleCat
Booya! No problem - glad to help! Interesting that they aren't indifferent... Anywho, don't forget to answer your own question. :) - CDub

1 Answers

2
votes

Thanks to @CDub for his input.

I changed the stage names in deploy.rb from symbols to strings, and that made the difference:

set :stages, %w[staging production]
set :default_stage, 'staging'