2015-10-08 29 views
0

我嘗試創建REVISION文件與完全提交散列部署。回覆在capistrano任務使空文件

#early.. 
revision = %x[git rev-parse HEAD] 
set :revision, revision 

namespace :assets do 
    task :install do 
     on roles :all do 
      puts fetch(:revision, "") #it's good, print ee51dc1308a07cb0dfadd60b2a9d1b3485614034 

      execute :sh, "-c 'echo #{fetch(:revision, "")} > #{release_path}/REVISION2'" 

      execute :sh, "-c 'cat #{release_path}/REVISION2'" #empty output 

      execute :php, "#{release_path}/public/index.php assetic build" 
     end 
    end 
end 

因此,我有文件REVISION2沒有內容。

Capistrano的版本:3.4.0(耙版本:10.1.0) 開發機:Ubuntu的LTS 14.04.2部署 至CentOS 6.4發佈(最終)

回答

0

我通過寫字的修訂文件,解決這個問題本地,然後用以下任務上傳:

task :save_revision do 
    revision = %x[git rev-parse HEAD] 

    File.open("REVISION", 'w') { |file| file.write(revision) } 

    set :revision, revision #save for future 
    puts revision #print 

    on roles :all do 
     upload! "REVISION", "#{release_path}" 
    end 
end