Class: EmailNotification
- Inherits:
-
Notification
- Object
- Notification
- EmailNotification
- Defined in:
- lib/kwala/notifications/email.rb
Instance Method Summary collapse
Methods inherited from Notification
add_notification, context, context=, notifications, notify, #notify, #undefined_event
Instance Method Details
#unit_test(result, data, context) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/kwala/notifications/email.rb', line 5 def unit_test(result, data, context) # TODO: Probably should move this to a configuration based from_addr = "" to_addr = [ "" ] smtp_server = "" smtp_port = 25 # Get the time and set the status msg now = Time.now status_msg = "Unit tests run #{result.to_s} at" # just file name for now data ||= {} data = Array(data[:filtered_results]).map do |d| d[:file_name] end if !data.empty? failure_msg = "Test files that reported failures:\n\#{data.join(\"\\n\")}\n" else failure_msg = '' end # Create the SMTP envelope msgstr = "From: Kwala Continuous Integration <EMAIL>\nTo: Edge Dev Mailing List <EMAIL>\nSubject: [Kwala] edge build \#{context.vcs_num} \#{result}\nDate: \#{now.strftime(\"%a, %d %b %Y %X +0900\")}\nMessage-Id: <\#{now.strftime(\"%m%d%Y%H%M%S\")}@EMAIL>\n\nResult Summary: \#{result.to_s}\nSee Results at https://BASEURL/kwala/\n\n\#{failure_msg}\n\nCommit Info:\n\#{context.vcs_info}\n END_OF_MESSAGE\n\n # Send the message\n Net::SMTP.start(smtp_server, smtp_port) do |smtp|\n smtp.send_message(msgstr, from_addr, *to_addr)\n end\nend\n" |