1

Etsyと同様に、Chefを使用して現在デプロイされているコミットハッシュをversion.txtファイルに書き込むための最良の方法は何ですか?これが私が思いついたものです。

execute "update_version" do
   command git log -1 --format="%H" > public/version.txt
   creates "#{app_config['deploy_dir']}/current/public/version.txt"
   owner app_user
   group app_group
   action:run
end
4

1 に答える 1

1
   owner app_user
   group app_group

実行リソースでは機能しない可能性があり ますhttp://wiki.opscode.com/display/chef/Resources#Resources-Execute

私は次のようなことをするかもしれません

bash "update_revision" do
   code "git log -1 --format="%H" > public/version.txt"
   creates "#{app_config['deploy_dir']}/current/public/version.txt"
end

file "public/version.txt" do
  owner app_user
  group app_group
  mode  0644
end

または、次のようなコンテンツでテンプレートを作成することもできます

<%= shell_out!('git log -1 --format="%H"') %>

次のようなテンプレートリソースを使用します

template( "public/version.txt") do
      owner app_user
      group app_group
      mode  0644
end
于 2012-11-12T11:04:27.677 に答える