8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

デプロイしたリビジョンをファイルに書き出す

Last updated at Posted at 2014-01-06

追記

Capistrano 3.1からは何もしなくてもprevious_revisionとcurrent_revisionが set されるようです。


Capistrano2の頃はデプロイするとそのときのリビジョンがREVISIONという名前のファイルに書きだされていた(ような気がする)のですが、Capistrano3ではデフォルトでそういうことをやらなくなったみたいです。

下記のタスクを追加するとファイルに保存されるようになります。

config/deploy.rb
set :revision_file, 'REVISION'

namespace :deploy do
  task :save_current_revision do
    on role(:app) do
      within repo_path do
        set :revision, capture(:git, :'rev-parse', fetch(:branch))
      end
      within release_path do
        execute :echo "#{fetch :current_revision} > #{fetch :revision_file}"
      end
    end
  end

  before :updated, 'deploy:save_current_revision'
end
8
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?