我有一个简短的多级capistrano脚本,它指定了一个默认阶段(set :default_stage, :staging
),但我发现当我在命令行中指定另一个阶段(例如cap production deploy
)时,我会发现分段和生产任务运行:
$ cap production deploy
triggering load callbacks
* 2013-06-19 06:38:34 executing `staging'
* 2013-06-19 06:38:34 executing `production'
因此,部署过程在staging.rb(本地存储库)指定的位置中查找scm,因此生产服务器不存在该scm,并且我的部署失败。
我可以在部署脚本中提供默认阶段,但在命令行中指定另一个阶段时是否可以加载它?
您可以在此处查看我的部署文件:
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
答案 0 :(得分:2)
感谢@CDub的投入。
我将deploy.rb中的阶段名称从符号更改为字符串,这就产生了不同:
set :stages, %w[staging production]
set :default_stage, 'staging'