From: Garming Sam Date: Mon, 14 Mar 2016 01:18:54 +0000 (+1300) Subject: autobuild: Return the last 50 log lines X-Git-Tag: samba-4.3.12~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bf9c4b683544ccf2aa2ae3efcf53d8777d1434f;p=thirdparty%2Fsamba.git autobuild: Return the last 50 log lines This means that you don't have to deal with tars for quickly determining the cause of a failure. Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett (cherry picked from commit 3751ffbbe75524984a822d65f623a040ca79c8f7) --- diff --git a/script/autobuild.py b/script/autobuild.py index 54e88f95200..651f22b96df 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -515,7 +515,7 @@ def send_email(subject, text, log_tar): s.quit() def email_failure(status, failed_task, failed_stage, failed_tag, errstr, - elapsed_time, log_base=None): + elapsed_time, log_base=None, add_log_tail=True): '''send an email to options.email about the failure''' elapsed_minutes = elapsed_time / 60.0 user = os.getenv("USER") @@ -553,6 +553,23 @@ The top commit for the tree that was built was: ''' % (log_base, failed_tag, log_base, failed_tag, log_base, top_commit_msg) + if add_log_tail: + f = open("%s/%s.stdout" % (gitroot, failed_tag), 'r') + lines = f.readlines() + log_tail = "".join(lines[-50:]) + num_lines = len(lines) + if num_lines < 50: + # Also include stderr (compile failures) if < 50 lines of stdout + f = open("%s/%s.stderr" % (gitroot, failed_tag), 'r') + log_tail += "".join(f.readlines()[-(50-num_lines):]) + + text += ''' +The last 50 lines of log messages: + +%s + ''' % log_tail + f.close() + logs = os.path.join(gitroot, 'logs.tar.gz') send_email('autobuild failure on %s for task %s during %s' % (platform.node(), failed_task, failed_stage),