2015-01-12 119 views
0

我正在嘗試編寫一個Capistrano任務,將「部署」一個我寫給陪伴Rails項目的私人寶石。Capistrano任務git克隆私人寶石

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 [email protected]: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而不是轉換成gem_container_path。由於未在Gemfile中指示'vendor/git/my_gem /'中找到'my_gem',因此嘗試bundle install時部署任務繼續並失敗。

我期待克隆回購到/ var/www/project/releases/*/vendor/git/my_gem的任務,其中*替換爲Capistrano爲生成的DateTime戳記,此版本。

爲什麼Capistrano將repo克隆到我的遠程用戶的主目錄而不是指定的路徑?

+0

出於好奇?你能顯示'gem_path'的調試輸出是什麼? (僅供參考,您有'debug'行錯誤。'debug「Gem path:#{gem_container_path}」') – ptierno

+0

@PeteyT gem_path是'/ var/www/project/releases/20150112224830/vendor/git/my_gem' – whargrove

+0

whats使用'git @ github.username/my_gem.git';不應該讀取'[email protected]:username/my_gem.git'?試圖在這裏消除錯字。 – ptierno

回答

0

的問題是我執行語句:

execute 'git clone [email protected]:username/my_gem.git', gem_path 

我改成了

execute "git clone [email protected]:username/my_gem.git #{gem_path}" 

,並正在按目前預計。