106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/rscout.rb', line 106
def send_failure_notifications(config, env, output)
email_body = [output.txt.string, output.error.backtrace.join("\n")].join("\n")
if config.email_enabled && config.email
logger.info "Sending emails alert to #{config.email}"
begin
mail = Mail.new do
from RScout.options[:from_email]
to config.email
subject "RScout Alert: Tests failing on #{config.name.to_s.humanize.titleize} (#{env})"
add_file filename: 'results.html', content: output.html.string
["X-Priority"] = "1 (Highest)"
["X-MSMail-Priority"] = "High"
["Importance"] = "High"
text_part do
body email_body
end
end
mail.deliver!
rescue => e
logger.error "Failed to send email alert!"
logger.error e.message + "\n " + e.backtrace.join("\n ")
end
end
if config. && config.
logger.info "Triggering PagerDuty incident to #{config.}"
begin
if config..match(/@(.*)pagerduty.com$/)
mail = Mail.new do
from RScout.options[:from_email]
to config.
subject "DOWN alert: RScout tests failing on #{config.name.to_s.humanize.titleize} (#{env})"
body email_body
end
mail.deliver!
else
p = Pagerduty.new config., ['scout', env].join('_')
incident = p.trigger 'RScout tests failing!', output.results
end
rescue => e
logger.error "Failed to send PagerDuty alert!"
logger.error e.message + "\n " + e.backtrace.join("\n ")
end
end
end
|