Add mail notifier

This commit is contained in:
Guillaume Dott 2015-05-26 11:25:40 +02:00
parent 85d2c6158d
commit 11d7ce7a10
3 changed files with 38 additions and 0 deletions

View File

@ -1,2 +1,3 @@
require 'capistrano/send/mail'
require 'capistrano/send/libnotify'
require 'capistrano/send/notify-send'

View File

@ -0,0 +1,16 @@
begin
require 'mail'
rescue LoadError
end
module Capistrano
module Send
module Mail
def self.supported?
defined?(::Mail)
end
end
end
end
load File.expand_path('../../tasks/mail.cap', __FILE__)

View File

@ -0,0 +1,21 @@
namespace :send do
namespace :mail do
desc "Send an email when deploy is finished"
task :notify do
if Capistrano::Send::Mail.supported?
config = fetch(:send_mail, {})
Mail.deliver do
to config[:to]
from config[:from]
subject "Deploy successful on #{fetch(:stage)}!"
body revision_log_message
delivery_method config[:via] || :smtp, config[:via_options] || {}
end
end
end
end
end
after 'deploy:finished', 'send:mail:notify'