Capistrano 3:如何将git修订版存储到文件中?

时间:2013-11-03 22:11:33

标签: capistrano capistrano3

有没有办法从Capistrano 3获取git修订版变量?

我无法弄清楚如何访问capistrano变量:

namespace :deploy do

  after :finished, :set_current_version do
    on roles(:app) do
      # dump current git version
      within release_path do
        execute :echo, "#{fetch(:revision_log_message)} >> public/version"
      end
    end
  end
end

2 个答案:

答案 0 :(得分:8)

这个有效

  after :finished, :set_current_version do
    on roles(:app) do
      # dump current git version
      within release_path do
        execute :echo, "#{capture("cd #{repo_path} && git rev-parse --short HEAD")} >> public/version"
      end
    end
  end

答案 1 :(得分:1)

3.0.1中添加了此功能,请参阅更改日志!