我一直在使用此要点在部署后发送电子邮件,但我希望该消息包含待处理的更改。
我无法弄清楚如何将cap deploy:pending
的响应转换为可添加到电子邮件中的变量。
https://gist.github.com/955917
How to use it?
1. Add this file to config/deploy folder.
2. Update the file with your google credentials and from email address.
3. Add the following content to config/deploy.rb.
require 'config/deploy/cap_notify.rb'
# add email addresses for people who should receive deployment notifications
set :notify_emails, ["EMAIL1@YOURDOMAIN.COM", "EMAIL2@YOURDOMAIN.COM"]
after :deploy, 'deploy:send_notification'
# Create task to send a notification
namespace :deploy do
desc "Send email notification"
task :send_notification do
Notifier.deploy_notification(self).deliver
end
end
4. Update deploy.rb with destination email addresses for the notifications.
5. To test run this command:
cap deploy:send_notification
=end
require "action_mailer"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:tls => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => "plain",
:user_name => "YOUR USER NAME",
:password => "YOUR PASSWORD"
}
class Notifier < ActionMailer::Base
default :from => "YOUR FROM EMAIL"
def deploy_notification(cap_vars)
now = Time.now
msg = "Performed a deploy operation on #{now.strftime("%m/%d/%Y")} at #{now.strftime("%I:%M %p")} to #{cap_vars.host}"
mail(:to => cap_vars.notify_emails,
:subject => "Deployed #{cap_vars.application} to #{cap_vars.stage}") do |format|
format.text { render :text => msg}
format.html { render :text => "<p>" + msg + "<\p>"}
end
端 端
答案 0 :(得分:0)
只需使用反引号?
str = `cap deploy:pending`