adding mail status notifications to taskotron buildmaster
This commit is contained in:
parent
b5ea5af7f5
commit
427480c594
1 changed files with 73 additions and 10 deletions
|
@ -212,16 +212,79 @@ c['status'].append(html.WebStatus(http_port=8080, authz=authz_cfg,
|
||||||
change_hook_dialects={'base':True}))
|
change_hook_dialects={'base':True}))
|
||||||
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
|
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
|
||||||
|
|
||||||
#from buildbot.status.mail import MailNotifier
|
from buildbot.status.mail import MailNotifier
|
||||||
#
|
from buildbot.status.builder import Results
|
||||||
#mn = MailNotifier(fromaddr="yagisama@gmail.com",
|
|
||||||
# sendToInterestedUsers=False,
|
import cgi
|
||||||
# extraRecipients=["goat@tirfa.com"],
|
|
||||||
# useTls=True, relayhost="smtp.gmail.com", smtpPort=587,
|
# http://docs.buildbot.net/current/manual/cfg-statustargets.html#mailnotifier
|
||||||
# smtpUser="yagisama", smtpPassword="Somehw3r",
|
def html_message_formatter(mode, name, build, results, master_status):
|
||||||
# mode='all')
|
"""Provide a customized message to Buildbot's MailNotifier.
|
||||||
#
|
|
||||||
#c['status'].append(mn)
|
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'<h4>Build status: %s</h4>' % result.upper())
|
||||||
|
text.append(u'<table cellspacing="10"><tr>')
|
||||||
|
text.append(u"<td>Buildslave for this Build:</td><td><b>%s</b></td></tr>" % build.getSlavename())
|
||||||
|
if master_status.getURLForThing(build):
|
||||||
|
text.append(u'<tr><td>Complete logs for all build steps:</td><td><a href="%s">%s</a></td></tr>'
|
||||||
|
% (master_status.getURLForThing(build),
|
||||||
|
master_status.getURLForThing(build))
|
||||||
|
)
|
||||||
|
text.append(u'<tr><td>Build Reason:</td><td>%s</td></tr>' % build.getReason())
|
||||||
|
text.append(u'</table>')
|
||||||
|
text.append(u'<br>')
|
||||||
|
|
||||||
|
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'<i>Detailed log of last build step:</i> <a href="%s">%s</a>'
|
||||||
|
% (url, url))
|
||||||
|
text.append(u'<br>')
|
||||||
|
text.append(u'<h4>Last %d lines of "%s"</h4>' % (limit_lines, name))
|
||||||
|
unilist = list()
|
||||||
|
for line in content[len(content)-limit_lines:]:
|
||||||
|
unilist.append(cgi.escape(unicode(line,'utf-8')))
|
||||||
|
text.append(u'<pre>')
|
||||||
|
text.extend(unilist)
|
||||||
|
text.append(u'</pre>')
|
||||||
|
text.append(u'<br><br>')
|
||||||
|
text.append(u'<b>-The Buildbot</b>')
|
||||||
|
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
|
####### PROJECT IDENTITY
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue