Capistrano::Configuration.instance(:must_exist).load do namespace :campfire do desc "Send message to campfire room about deploy lifecycle events" task :notify do [campfire_account, campfire_token, campfire_room].each do |setting| abort("Campfire notifications require 'campfire_token', 'campfire_account', & 'campfire_room' to be set") unless setting end lobby = Tinder::Campfire.new campfire_account, :ssl => true, :token => campfire_token room = lobby.find_room_by_name(campfire_room) room.speak(fetch(:campfire_message)) end namespace :message do desc "Send a message to campfire room about beginning a deploy" task :start, :except => { :no_campfire => true } do set :campfire_message, "Starting deploy on server #{rails_env} with #{branch}/#{real_revision[0, 7]} to #{deploy_to}" notify end desc "Send a message to campfire room about completing a deploy" task :finish, :except => { :no_campfire => true } do set :campfire_message, "Finished deploy on server #{rails_env} with #{branch}/#{real_revision[0, 7]} to #{deploy_to}" notify end desc "Send a message to campfire room about rollingback a deploy" task :rollback, :except => { :no_campfire => true } do set :campfire_message, "Rolling back deploy on server #{rails_env} from #{latest_revision[0, 7]} to #{previous_revision[0, 7]} to #{deploy_to}" notify end end end _cset(:campfire, true) #Use campfire by default for any environment if campfire before "deploy", "campfire:message:start" after "deploy", "campfire:message:finish" after "deploy:rollback", "campfire:message:rollback" end end