Commit d3eefb8c authored by Andrew Gerrand's avatar Andrew Gerrand

dashboard: include last 100 lines in build failure mail

R=golang-dev, rsc, iant, robert.hencke
CC=golang-dev
https://golang.org/cl/5235041
parent b536adbf
...@@ -4,3 +4,6 @@ http://godashboard.appspot.com/log/{{loghash}} ...@@ -4,3 +4,6 @@ http://godashboard.appspot.com/log/{{loghash}}
{{desc}} {{desc}}
http://code.google.com/p/go/source/detail?r={{node}} http://code.google.com/p/go/source/detail?r={{node}}
$ tail -n 100 < log
{{log}}
...@@ -343,7 +343,7 @@ class Build(webapp.RequestHandler): ...@@ -343,7 +343,7 @@ class Build(webapp.RequestHandler):
c = getBrokenCommit(node, builder) c = getBrokenCommit(node, builder)
if c is not None and not c.fail_notification_sent: if c is not None and not c.fail_notification_sent:
notifyBroken(c, builder) notifyBroken(c, builder, log)
self.response.set_status(200) self.response.set_status(200)
...@@ -388,7 +388,7 @@ def nodeBefore(c): ...@@ -388,7 +388,7 @@ def nodeBefore(c):
def nodeAfter(c): def nodeAfter(c):
return Commit.all().filter('parenthash', c.node).get() return Commit.all().filter('parenthash', c.node).get()
def notifyBroken(c, builder): def notifyBroken(c, builder, log):
def send(): def send():
n = Commit.get(c.key()) n = Commit.get(c.key())
if n is None: if n is None:
...@@ -399,7 +399,10 @@ def notifyBroken(c, builder): ...@@ -399,7 +399,10 @@ def notifyBroken(c, builder):
n.fail_notification_sent = True n.fail_notification_sent = True
return n.put() return n.put()
if not db.run_in_transaction(send): if not db.run_in_transaction(send):
return return
# get last 100 lines of the build log
log = '\n'.join(log.split('\n')[-100:])
subject = const.mail_fail_subject % (builder, c.desc.split('\n')[0]) subject = const.mail_fail_subject % (builder, c.desc.split('\n')[0])
path = os.path.join(os.path.dirname(__file__), 'fail-notify.txt') path = os.path.join(os.path.dirname(__file__), 'fail-notify.txt')
...@@ -408,7 +411,8 @@ def notifyBroken(c, builder): ...@@ -408,7 +411,8 @@ def notifyBroken(c, builder):
"node": c.node, "node": c.node,
"user": c.user, "user": c.user,
"desc": c.desc, "desc": c.desc,
"loghash": logHash(c, builder) "loghash": logHash(c, builder),
"log": log,
}) })
mail.send_mail( mail.send_mail(
sender=const.mail_from, sender=const.mail_from,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment