I have written a capistrano plugin that will send emails when new
releases are deployed using capistrano.  It is released under the MIT
license.

Here's the readme:

Capistrano Mailer
=================

Ever wanted to be emailed whenever someone on the team does a cap
deploy of trunk or some tag to some server.
Wouldn't it be nice to know about it every time a release was
deployed?  For large rails projects this type of coordination is
essential,
and this plugin makes sure everyone on the need to know list is
notified when something new is deployed.

This plugin is an extension to Capistrano.

That means it registers itself with Capistrano as a plugin and is
therefore available to call in your recipes.

Home Page
=========

http://code.google.com/p/capistrano-mailer/

Installation
============

./script/plugin install 
http://capistrano-mailer.googlecode.com/svn/trunk/capistrano_mailer

Usage
=====

1. Install the plugin.

2. Add this line to the top of your deploy.rb:

require 'vendor/plugins/capistrano_mailer/lib/capistrano_mailer'

3. Add a cap_mailer_settings.rb file to your config/ directory:

require 'vendor/plugins/capistrano_mailer/lib/cap_mailer'

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address        => "mail.default.com",
  :port           => 25,
  :domain         => 'default.com',
  :perform_deliveries => true,
  :user_name      => "[EMAIL PROTECTED]",
  :password       => "mypassword",
  :authentication => :login }
ActionMailer::Base.default_charset = "latin1"

CapMailer.recipient_addresses = ["[EMAIL PROTECTED]"]
CapMailer.sender_address = %("Capistrano Deployment"
<[EMAIL PROTECTED]>)
CapMailer.email_prefix = "[MYSITE-CAP-DEPLOY]"
CapMailer.site_name = "MySite.com"
CapMailer.email_content_type = "text/html"

4. Add these two tasks to your deploy.rb:

namespace :show do
  desc "Show some internal Cap-Fu: What's mah NAYM?!?"
  task :me do
    set :command, task_call_frames.first.task.fully_qualified_name
    puts "echo 'Running #{command} task'"
  end
end

namespace :deploy do
  ...

  desc "Send email notification of deployment"
  task :notify, :roles => :app do
    show.me
    mailer.send(rails_env, repository, command, deploy_to, host)
  end

  ...
end

Make sure you've defined rails_env, repository, deploy_to and host.
command is defined by the show:me task above.

The only parameters to mailer.send that are required are rails_env,
repository, command and deploy_to.
The complete set of possible parameters is:
mailer.send(rails_env, repository, command, deploy_to, host = nil,
ip_address = nil, output = nil)

If anyone has a cool way of recording the output into a capistrano
accessible variable,
so that it can be shoved into the release email that would be an
excellent contribution!

5. Then add the hook somewhere in your deploy.rb:

after "deploy", "deploy:notify"

6. Enjoy and Happy Capping!

----------------------------------------------------------------------------------
        This plugin is a creation of Sagebit, LLC. (http://www.sagebit.com)

        Author: Peter Boling, peter.boling at gmail dot com

        Copyright (c) 2007 Sagebit LLC, released under the MIT license
--~--~---------~--~----~------------~-------~--~----~
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