zargony.com

#![desc = "Random thoughts of a software engineer"]

Getting an old-style revisions.log with Capistrano 2.0

Capistrano 2.0 does not write a revisions.log anymore when deploying your application. However, I liked the revisions.log, because it gives you a clear history of which revision you deployed to your servers at which time. Therefore I wrote a little Capistrano recipe which updates an old-style revisions.log whenever you deploy or rollback your appliaction.

Adding the following statements to your Capfile will write an old-style revisions.log when deploying or rolling back your application, like Capistrano 1.x did:

namespace :deploy do
  desc <<-DESC
    [internal] Adds a line to revisions.log after updating the code
  DESC
  task :update_revisions_log, :except => { :no_release => true } do
    timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S')
    run "echo '#{timestamp} #{user} #{latest_revision} #{releases.last}' >>#{deploy_to}/revisions.log"
  end
end
after 'deploy:update_code', 'deploy:update_revisions_log'
after 'deploy:rollback_code', 'deploy:update_revisions_log'