Capistrano 3: How to save git version to file?

Is there a way to get the git revision variable from Capistrano 3?

I cannot figure out how to access capistrano variables:

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
+4
source share
2 answers

It works

  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
+8
source

This feature was added in 3.0.1, see their change log!

+1
source

All Articles