我正在尝试编写一个能够部署'部署的Capistrano任务。我写的一个私人宝石伴随着Rails项目。
在config/deploy.rb
after :updating, :retrieve_my_gem
文件lib/capistrano/tasks/retrieve_my_gem.rake
包含...
desc 'Clones my_gem from Github to vendor/git'
task :retrieve_my_gem do
on roles(:app), in: :sequence do
# Create the directory that will contain my gem
gem_container_path = release_path.join('vendor/git')
debug "Gem container path: #{gem_container_path}"
if test "[ ! -d #{gem_container_path} ]"
info "Creating local gem directory"
execute 'mkdir', '-p', gem_container_path
end
gem_path = release_path.join('vendor/git/my_gem')
debug "Gem path: #{gem_path}"
if test "[ ! -d #{gem_path} ]"
within gem_container_path do
info "Cloning my gem to #{gem_path}"
execute 'git clone git@github.com:username/my_gem.git', gem_path
end
else
within gem_path do
info "Updating my gem in #{gem_path}"
execute 'git pull'
end
end
end
end
Gemfile
有...
gem 'my_gem', :path => 'vendor/git/my_gem/'
当我运行部署任务时,gem_container_path
已创建,但它将回购my_gem
克隆到〜/ my_gem而不是gem_container_path
。由于未找到“my_gem”,尝试bundle install
时,部署任务会继续并失败。在' vendor / git / my_gem /'如Gemfile中所示。
我期望将任务克隆到/ var / www / project / releases / * / vendor / git / my_gem,其中*替换为Capistrano为此版本生成的DateTime标记
为什么Capistrano将repo克隆到我的远程用户的主目录而不是指定的路径?
答案 0 :(得分:0)
问题是我的执行声明:
execute 'git clone git@github.com:username/my_gem.git', gem_path
我把它改成了
execute "git clone git@github.com:username/my_gem.git #{gem_path}"
现在正按预期工作。