簡體   English   中英

Ruby on Rails:Bundler和Capistrano:指定在部署時要排除的組(開發,測試)

[英]Ruby on Rails: Bundler & Capistrano: specify which groups (development, test) are to be excluded when deploying

Bundler文檔說,為了在通過Capistrano進行部署時安裝所有必需的捆綁軟件,只需插入

require 'bundler/capistrano' # siehe http://gembundler.com/deploying.html

在他的deploy.rb中。 然后,在部署后,Capistrano致電

  * executing "bundle install --gemfile .../releases/20110403085518/Gemfile \
    --path .../shared/bundle --deployment --quiet --without development test"

這很好。

但是,我們在生產服務器上有一個暫存設置,與真實的實時站點隔離開來,在該站點上,我們使用(克隆和防火牆)實時生產數據測試新的應用程序版本。 在那里,我們需要安裝測試和開發工具。

如何在此處指定capistrano命令行? 是否可以使用參數,還是需要設置自己的capistrano任務來覆蓋Bundler的參數?

謝謝!

編寫不同的任務肯定會使事情變得簡單:

task :production do
  # These are default settings
  set :bundle_without, [:development, :test]
end

task :staging do
  set :bundle_without, [:test]
  # set :rails_env, 'staging'
end

但是,如果要使用命令行選項,則可以打開提供的值:

cap deploy target=staging

在您的deploy.rb文件中,您可以將option值用作:

if target == "staging"
  set :bundle_without, [:test]
  # do other stuff here
end

您還可以使用一個更“合適”的配置對象。 我在這里找到了對它的引用: http : //ryandaigle.com/articles/2007/6/22/using-command-line-parameters-w-rake-and-capistrano

我認為最干凈的方法是使用以下命令在您的部署環境文件中僅添加set:bundle_without:

https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension

我沒有獨立確認的設置,但是RAILS_ENV ='development'可以得到它嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM