
在部署過程中,我想在 capistrano 部署期間在 /current 資料夾中建立 .rvmrc 檔案。
我怎樣才能做到這一點?
答案1
您可以使用如下所示的語法將任務新增至 Capistrano 部署:
task :gitinstall do
run "apt-get update"
run "apt-get -y install git-core"
end
before "deploy:update", :gitinstall
此範例讓每台電腦在執行部署之前安裝 git。您所要做的就是修改它以 wget 有問題的檔案或執行 bash echo。
答案2
我將把它留在這裡作為參考。應該與較新版本的 rbenv 或 rvm 一起使用。
namespace :deploy do
desc 'Sets the ruby version'
task :set_ruby_version do
put "2.0.0-p0", "#{latest_release}/.ruby-version"
end
end
after 'deploy:update_code', 'deploy:set_ruby_version'
或者,如果您使用的是 capistrano/bundler,則需要這個鉤子:
before 'bundle:install', 'deploy:set_ruby_version'