diff --git a/roles/taskotron/buildmaster-configure/templates/taskotron.master.cfg.j2 b/roles/taskotron/buildmaster-configure/templates/taskotron.master.cfg.j2
index 50d80220de..a9e716f91e 100644
--- a/roles/taskotron/buildmaster-configure/templates/taskotron.master.cfg.j2
+++ b/roles/taskotron/buildmaster-configure/templates/taskotron.master.cfg.j2
@@ -212,16 +212,79 @@ c['status'].append(html.WebStatus(http_port=8080, authz=authz_cfg,
change_hook_dialects={'base':True}))
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
-#from buildbot.status.mail import MailNotifier
-#
-#mn = MailNotifier(fromaddr="yagisama@gmail.com",
-# sendToInterestedUsers=False,
-# extraRecipients=["goat@tirfa.com"],
-# useTls=True, relayhost="smtp.gmail.com", smtpPort=587,
-# smtpUser="yagisama", smtpPassword="Somehw3r",
-# mode='all')
-#
-#c['status'].append(mn)
+from buildbot.status.mail import MailNotifier
+from buildbot.status.builder import Results
+
+import cgi
+
+# http://docs.buildbot.net/current/manual/cfg-statustargets.html#mailnotifier
+def html_message_formatter(mode, name, build, results, master_status):
+ """Provide a customized message to Buildbot's MailNotifier.
+
+ The last 80 lines of the log are provided as well as the changes
+ relevant to the build. Message content is formatted as html.
+ """
+ result = Results[results]
+
+ limit_lines = 80
+ text = list()
+ text.append(u'
Build status: %s
' % result.upper())
+ text.append(u'')
+ text.append(u"Buildslave for this Build: | %s |
" % build.getSlavename())
+ if master_status.getURLForThing(build):
+ text.append(u'Complete logs for all build steps: | %s |
'
+ % (master_status.getURLForThing(build),
+ master_status.getURLForThing(build))
+ )
+ text.append(u'Build Reason: | %s |
' % build.getReason())
+ text.append(u'
')
+ text.append(u'
')
+
+ logs = []
+ steps = build.getSteps()
+ for step in steps:
+ if step.getName() == 'runtask':
+ logs = step.getLogs()
+ break
+
+ # logs within a step are in reverse order. Search back until we find stdio
+ for log in reversed(logs):
+ if log.getName() == 'stdio':
+ break
+
+ name = "%s.%s" % (log.getStep().getName(), log.getName())
+ content = log.getText().splitlines() # Note: can be VERY LARGE
+ url = u'%s/steps/%s/logs/%s' % (master_status.getURLForThing(build),
+ log.getStep().getName(),
+ log.getName())
+
+ text.append(u'Detailed log of last build step: %s'
+ % (url, url))
+ text.append(u'
')
+ text.append(u'Last %d lines of "%s"
' % (limit_lines, name))
+ unilist = list()
+ for line in content[len(content)-limit_lines:]:
+ unilist.append(cgi.escape(unicode(line,'utf-8')))
+ text.append(u'')
+ text.extend(unilist)
+ text.append(u'
')
+ text.append(u'
')
+ text.append(u'-The Buildbot')
+ return {
+ 'body': u"\n".join(text),
+ 'type': 'html'
+ }
+
+
+mn = MailNotifier(fromaddr='taskotron@fedoraproject.org',
+ sendToInterestedUsers=False,
+ mode=('failing', 'exception', 'warning'),
+ extraRecipients=['qa-taskotron-admin-members@fedoraproject.org'],
+ relayhost="bastion.phx2.fedoraproject.org",
+ messageFormatter=html_message_formatter)
+
+c['status'].append(mn)
+
####### PROJECT IDENTITY