Capistrano多个部署阶段

时间:2016-04-28 11:43:15

标签: ruby-on-rails deployment capistrano3

我有一个Rails应用程序,我想使用Capistrano部署两个版本:productionstaging

在我的deploy.rb文件中,我有: set :stages, ['staging', 'production']

那么如何在不覆盖它们的情况下使用两条路径呢?

set :deploy_to, '/home/deploy/Sites/staging/myname'

set :deploy_to, '/home/deploy/Sites/production/myname'

我见过this answer,但我想保持命令行清洁。

2 个答案:

答案 0 :(得分:2)

config/deploy/*.rbproduction.rbstaging.rb下创建两个文件,production.rb添加set :deploy_to, '/home/deploy/Sites/production/myname'staging.rb添加{{1 }}

Don't be lazy and read the Capistrano documentation

答案 1 :(得分:0)

可以为config/deploy.rb中的特定环境定义来自config/deploy/*的任何数据

config/deploy/production.rb

的示例
set :stage, :production
set :rails_env, :production
set :branch, "master"

config/deploy/staging.rb

的示例
set :stage, :staging
set :rails_env, :staging
set :branch, "staging"

这对我来说适用于来自不同分支的两个环境。 希望您也明确定义:deploy_toserver url