我尝试在部署时使用完全提交哈希创建REVISION文件。
#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 14.04.2 LTS 部署到CentOS版本6.4(最终版)
答案 0 :(得分:1)
我通过在本地编写REVISION文件解决了这个问题,然后使用以下任务上传
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