I've got this simple email notifier task below that runs after my main
deployment tasks, and I'd like it to show the command or even the
command-line that kicked everything off.  The attempt below uses some
fancy code that I blatantly cribbed from the show.me task in the
excellent capistrano-mailer plugin, but I find it doesn't work, at
least not in an after hook.  It just returns "email_notify" instead of
"deploy" or "deploy:migrations"

###################################################################
desc "send out notification email from server after deployment"
task :email_notify, :roles => :app do
  message_body = <<-CMD
From: "Capistrano" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [DEPLOYMENT - #{rails_env}]
Content-Type: text/plain

#{rails_env} has been updated!

Command:    #{task_call_frames.first.task.fully_qualified_name}
User:       #{ENV['USERNAME'] || ENV['USER'] || 'unknown'}
Time:       #{Time.now.to_s}

Location:   #{release_path}

Repository: #{repository}
Revision:   #{current_revision} (was: #{previous_revision})
        CMD
  put message_body, "/tmp/cap_#{rails_env}_mail.txt"
  run "/usr/sbin/sendmail -t < /tmp/cap_#{rails_env}_mail.txt"
end

# send email and tidy up release directory
after "deploy", "email_notify"
after "deploy", "deploy:cleanup"
after "deploy:migrations", "email_notify"
after "deploy:migrations", "deploy:cleanup"
###################################################################

I'm a relative Ruby novice, so I'd be happy with the original raw
cmdline or just the top-level task.

Thanks,
    Mark

PS: I'm sending from the servers via ssmtp (which simulates sendmail)
because it seemed easier to configure a few servers than to verify
outbound email worked for the variety of developer client boxes I have
to support.
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to