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