s3:move serverid_equal() to serverid.c
[Samba/gebeck_regimport.git] / script / autobuild.py
blob8bdb281bbd2cb412e48067e3f58cfb41cd6b81de
1 #!/usr/bin/env python
2 # run tests on all Samba subprojects and push to a git tree on success
3 # Copyright Andrew Tridgell 2010
4 # released under GNU GPL v3 or later
6 from subprocess import call, check_call,Popen, PIPE
7 import os, tarfile, sys, time
8 from optparse import OptionParser
9 import smtplib
10 from email.mime.text import MIMEText
11 from distutils.sysconfig import get_python_lib
13 samba_master = os.getenv('SAMBA_MASTER', 'git://git.samba.org/samba.git')
14 samba_master_ssh = os.getenv('SAMBA_MASTER_SSH', 'git+ssh://git.samba.org/data/git/samba.git')
16 cleanup_list = []
18 builddirs = {
19 "samba3" : "source3",
20 "samba4" : ".",
21 "samba4-libs" : ".",
22 "ldb" : "lib/ldb",
23 "tdb" : "lib/tdb",
24 "ntdb" : "lib/ntdb",
25 "talloc" : "lib/talloc",
26 "replace" : "lib/replace",
27 "tevent" : "lib/tevent",
28 "pidl" : "pidl",
29 "pass" : ".",
30 "fail" : ".",
31 "retry" : "."
34 defaulttasks = [ "samba3", "samba4", "samba4-libs", "ldb", "tdb", "ntdb", "talloc", "replace", "tevent", "pidl" ]
36 tasks = {
37 "samba3" : [ ("autogen", "./autogen.sh", "text/plain"),
38 ("configure", "./configure.developer ${PREFIX}", "text/plain"),
39 ("make basics", "make basics", "text/plain"),
40 # we split 'make -j 4', 'make bin/smbtorture4' and 'make -j 4 everything'
41 # because it makes it much easier to find errors.
42 ("make", "make -j 4", "text/plain"), # don't use too many processes
43 ("make bin/smbtorture4", "make bin/smbtorture4", "text/plain"),
44 ("make everything", "make -j 4 everything", "text/plain"),
45 ("install", "make install", "text/plain"),
46 ("test", "TDB_NO_FSYNC=1 make test FAIL_IMMEDIATELY=1", "text/plain"),
47 ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"),
48 ("clean", "make clean", "text/plain") ],
50 # We have 'test' before 'install' because, 'test' should work without 'install'
51 "samba4" : [ ("configure", "./configure.developer ${PREFIX} --with-selftest-prefix=./bin/ab", "text/plain"),
52 ("make", "make -j", "text/plain"),
53 ("test", "TDB_NO_FSYNC=1 make test FAIL_IMMEDIATELY=1", "text/plain"),
54 ("install", "make install", "text/plain"),
55 ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"),
56 ("clean", "make clean", "text/plain") ],
58 "samba4-libs" : [
59 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
60 ("talloc-configure", "cd lib/talloc && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
61 ("talloc-make", "cd lib/talloc && make", "text/plain"),
62 ("talloc-install", "cd lib/talloc && make install", "text/plain"),
64 ("tdb-configure", "cd lib/tdb && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
65 ("tdb-make", "cd lib/tdb && make", "text/plain"),
66 ("tdb-install", "cd lib/tdb && make install", "text/plain"),
68 ("tevent-configure", "cd lib/tevent && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
69 ("tevent-make", "cd lib/tevent && make", "text/plain"),
70 ("tevent-install", "cd lib/tevent && make install", "text/plain"),
72 ("ldb-configure", "cd lib/ldb && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
73 ("ldb-make", "cd lib/ldb && make", "text/plain"),
74 ("ldb-install", "cd lib/ldb && make install", "text/plain"),
76 ("configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=!talloc,!tdb,!pytdb,!ldb,!pyldb,!tevent,!pytevent --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
77 ("make", "make", "text/plain"),
78 ("install", "make install", "text/plain")],
80 "ldb" : [
81 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
82 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
83 ("make", "make", "text/plain"),
84 ("install", "make install", "text/plain"),
85 ("test", "TDB_NO_FSYNC=1 make test", "text/plain"),
86 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
87 ("distcheck", "make distcheck", "text/plain"),
88 ("clean", "make clean", "text/plain") ],
90 # We don't use TDB_NO_FSYNC=1 here, because we want to test the transaction code
91 "tdb" : [
92 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
93 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
94 ("make", "make", "text/plain"),
95 ("install", "make install", "text/plain"),
96 ("test", "make test", "text/plain"),
97 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
98 ("distcheck", "make distcheck", "text/plain"),
99 ("clean", "make clean", "text/plain") ],
101 "ntdb" : [
102 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
103 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
104 ("make", "make", "text/plain"),
105 ("install", "make install", "text/plain"),
106 ("test", "make test", "text/plain"),
107 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
108 ("distcheck", "make distcheck", "text/plain"),
109 ("clean", "make clean", "text/plain") ],
111 "talloc" : [
112 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
113 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
114 ("make", "make", "text/plain"),
115 ("install", "make install", "text/plain"),
116 ("test", "make test", "text/plain"),
117 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
118 ("distcheck", "make distcheck", "text/plain"),
119 ("clean", "make clean", "text/plain") ],
121 "replace" : [
122 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
123 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
124 ("make", "make", "text/plain"),
125 ("install", "make install", "text/plain"),
126 ("test", "make test", "text/plain"),
127 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
128 ("distcheck", "make distcheck", "text/plain"),
129 ("clean", "make clean", "text/plain") ],
131 "tevent" : [
132 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
133 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
134 ("make", "make", "text/plain"),
135 ("install", "make install", "text/plain"),
136 ("test", "make test", "text/plain"),
137 ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
138 ("distcheck", "make distcheck", "text/plain"),
139 ("clean", "make clean", "text/plain") ],
141 "pidl" : [
142 ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
143 ("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}", "text/plain"),
144 ("touch", "touch *.yp", "text/plain"),
145 ("make", "make", "text/plain"),
146 ("test", "make test", "text/plain"),
147 ("install", "make install", "text/plain"),
148 ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"),
149 ("clean", "make clean", "text/plain") ],
151 # these are useful for debugging autobuild
152 'pass' : [ ("pass", 'echo passing && /bin/true', "text/plain") ],
153 'fail' : [ ("fail", 'echo failing && /bin/false', "text/plain") ]
156 retry_task = [ ( "retry",
157 '''set -e
158 git remote add -t master master %s
159 git fetch master
160 while :; do
161 sleep 60
162 git describe master/master > old_master.desc
163 git fetch master
164 git describe master/master > master.desc
165 diff old_master.desc master.desc
166 done
167 ''' % samba_master, "test/plain" ) ]
169 def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True):
170 if show is None:
171 show = options.verbose
172 if show:
173 print("Running: '%s' in '%s'" % (cmd, dir))
174 if output:
175 return Popen([cmd], shell=True, stdout=PIPE, cwd=dir).communicate()[0]
176 elif checkfail:
177 return check_call(cmd, shell=True, cwd=dir)
178 else:
179 return call(cmd, shell=True, cwd=dir)
182 class builder(object):
183 '''handle build of one directory'''
185 def __init__(self, name, sequence):
186 self.name = name
187 self.dir = builddirs[name]
189 self.tag = self.name.replace('/', '_')
190 self.sequence = sequence
191 self.next = 0
192 self.stdout_path = "%s/%s.stdout" % (gitroot, self.tag)
193 self.stderr_path = "%s/%s.stderr" % (gitroot, self.tag)
194 if options.verbose:
195 print("stdout for %s in %s" % (self.name, self.stdout_path))
196 print("stderr for %s in %s" % (self.name, self.stderr_path))
197 run_cmd("rm -f %s %s" % (self.stdout_path, self.stderr_path))
198 self.stdout = open(self.stdout_path, 'w')
199 self.stderr = open(self.stderr_path, 'w')
200 self.stdin = open("/dev/null", 'r')
201 self.sdir = "%s/%s" % (testbase, self.tag)
202 self.prefix = "%s/prefix/%s" % (testbase, self.tag)
203 run_cmd("rm -rf %s" % self.sdir)
204 cleanup_list.append(self.sdir)
205 cleanup_list.append(self.prefix)
206 os.makedirs(self.sdir)
207 run_cmd("rm -rf %s" % self.sdir)
208 run_cmd("git clone --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True)
209 self.start_next()
211 def start_next(self):
212 if self.next == len(self.sequence):
213 print '%s: Completed OK' % self.name
214 self.done = True
215 return
216 (self.stage, self.cmd, self.output_mime_type) = self.sequence[self.next]
217 self.cmd = self.cmd.replace("${PYTHON_PREFIX}", get_python_lib(standard_lib=1, prefix=self.prefix))
218 self.cmd = self.cmd.replace("${PREFIX}", "--prefix=%s" % self.prefix)
219 self.cmd = self.cmd.replace("${PREFIX_DIR}", "%s" % self.prefix)
220 # if self.output_mime_type == "text/x-subunit":
221 # self.cmd += " | %s --immediate" % (os.path.join(os.path.dirname(__file__), "selftest/format-subunit"))
222 print '%s: [%s] Running %s' % (self.name, self.stage, self.cmd)
223 cwd = os.getcwd()
224 os.chdir("%s/%s" % (self.sdir, self.dir))
225 self.proc = Popen(self.cmd, shell=True,
226 stdout=self.stdout, stderr=self.stderr, stdin=self.stdin)
227 os.chdir(cwd)
228 self.next += 1
231 class buildlist(object):
232 '''handle build of multiple directories'''
234 def __init__(self, tasklist, tasknames):
235 global tasks
236 self.tlist = []
237 self.tail_proc = None
238 self.retry = None
239 if tasknames == []:
240 tasknames = defaulttasks
241 for n in tasknames:
242 b = builder(n, tasks[n])
243 self.tlist.append(b)
244 if options.retry:
245 self.retry = builder('retry', retry_task)
246 self.need_retry = False
248 def kill_kids(self):
249 if self.tail_proc is not None:
250 self.tail_proc.terminate()
251 self.tail_proc.wait()
252 self.tail_proc = None
253 if self.retry is not None:
254 self.retry.proc.terminate()
255 self.retry.proc.wait()
256 self.retry = None
257 for b in self.tlist:
258 if b.proc is not None:
259 run_cmd("killbysubdir %s > /dev/null 2>&1" % b.sdir, checkfail=False)
260 b.proc.terminate()
261 b.proc.wait()
262 b.proc = None
264 def wait_one(self):
265 while True:
266 none_running = True
267 for b in self.tlist:
268 if b.proc is None:
269 continue
270 none_running = False
271 b.status = b.proc.poll()
272 if b.status is None:
273 continue
274 b.proc = None
275 return b
276 if options.retry:
277 ret = self.retry.proc.poll()
278 if ret is not None:
279 self.need_retry = True
280 self.retry = None
281 return None
282 if none_running:
283 return None
284 time.sleep(0.1)
286 def run(self):
287 while True:
288 b = self.wait_one()
289 if options.retry and self.need_retry:
290 self.kill_kids()
291 print("retry needed")
292 return (0, None, None, None, "retry")
293 if b is None:
294 break
295 if os.WIFSIGNALED(b.status) or os.WEXITSTATUS(b.status) != 0:
296 self.kill_kids()
297 return (b.status, b.name, b.stage, b.tag, "%s: [%s] failed '%s' with status %d" % (b.name, b.stage, b.cmd, b.status))
298 b.start_next()
299 self.kill_kids()
300 return (0, None, None, None, "All OK")
302 def tarlogs(self, fname):
303 tar = tarfile.open(fname, "w:gz")
304 for b in self.tlist:
305 tar.add(b.stdout_path, arcname="%s.stdout" % b.tag)
306 tar.add(b.stderr_path, arcname="%s.stderr" % b.tag)
307 if os.path.exists("autobuild.log"):
308 tar.add("autobuild.log")
309 tar.close()
311 def remove_logs(self):
312 for b in self.tlist:
313 os.unlink(b.stdout_path)
314 os.unlink(b.stderr_path)
316 def start_tail(self):
317 cwd = os.getcwd()
318 cmd = "tail -f *.stdout *.stderr"
319 os.chdir(gitroot)
320 self.tail_proc = Popen(cmd, shell=True)
321 os.chdir(cwd)
324 def cleanup():
325 if options.nocleanup:
326 return
327 print("Cleaning up ....")
328 for d in cleanup_list:
329 run_cmd("rm -rf %s" % d)
332 def find_git_root():
333 '''get to the top of the git repo'''
334 p=os.getcwd()
335 while p != '/':
336 if os.path.isdir(os.path.join(p, ".git")):
337 return p
338 p = os.path.abspath(os.path.join(p, '..'))
339 return None
342 def daemonize(logfile):
343 pid = os.fork()
344 if pid == 0: # Parent
345 os.setsid()
346 pid = os.fork()
347 if pid != 0: # Actual daemon
348 os._exit(0)
349 else: # Grandparent
350 os._exit(0)
352 import resource # Resource usage information.
353 maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
354 if maxfd == resource.RLIM_INFINITY:
355 maxfd = 1024 # Rough guess at maximum number of open file descriptors.
356 for fd in range(0, maxfd):
357 try:
358 os.close(fd)
359 except OSError:
360 pass
361 os.open(logfile, os.O_RDWR | os.O_CREAT)
362 os.dup2(0, 1)
363 os.dup2(0, 2)
365 def write_pidfile(fname):
366 '''write a pid file, cleanup on exit'''
367 f = open(fname, mode='w')
368 f.write("%u\n" % os.getpid())
369 f.close()
372 def rebase_tree(url):
373 print("Rebasing on %s" % url)
374 run_cmd("git describe HEAD", show=True, dir=test_master)
375 run_cmd("git remote add -t master master %s" % url, show=True, dir=test_master)
376 run_cmd("git fetch master", show=True, dir=test_master)
377 if options.fix_whitespace:
378 run_cmd("git rebase --whitespace=fix master/master", show=True, dir=test_master)
379 else:
380 run_cmd("git rebase master/master", show=True, dir=test_master)
381 diff = run_cmd("git --no-pager diff HEAD master/master", dir=test_master, output=True)
382 if diff == '':
383 print("No differences between HEAD and master/master - exiting")
384 sys.exit(0)
385 run_cmd("git describe master/master", show=True, dir=test_master)
386 run_cmd("git describe HEAD", show=True, dir=test_master)
387 run_cmd("git --no-pager diff --stat HEAD master/master", show=True, dir=test_master)
389 def push_to(url):
390 print("Pushing to %s" % url)
391 if options.mark:
392 run_cmd("git config --replace-all core.editor script/commit_mark.sh", dir=test_master)
393 run_cmd("git commit --amend -c HEAD", dir=test_master)
394 # the notes method doesn't work yet, as metze hasn't allowed refs/notes/* in master
395 # run_cmd("EDITOR=script/commit_mark.sh git notes edit HEAD", dir=test_master)
396 run_cmd("git remote add -t master pushto %s" % url, show=True, dir=test_master)
397 run_cmd("git push pushto +HEAD:master", show=True, dir=test_master)
399 def_testbase = os.getenv("AUTOBUILD_TESTBASE", "/memdisk/%s" % os.getenv('USER'))
401 parser = OptionParser()
402 parser.add_option("", "--tail", help="show output while running", default=False, action="store_true")
403 parser.add_option("", "--keeplogs", help="keep logs", default=False, action="store_true")
404 parser.add_option("", "--nocleanup", help="don't remove test tree", default=False, action="store_true")
405 parser.add_option("", "--testbase", help="base directory to run tests in (default %s)" % def_testbase,
406 default=def_testbase)
407 parser.add_option("", "--passcmd", help="command to run on success", default=None)
408 parser.add_option("", "--verbose", help="show all commands as they are run",
409 default=False, action="store_true")
410 parser.add_option("", "--rebase", help="rebase on the given tree before testing",
411 default=None, type='str')
412 parser.add_option("", "--rebase-master", help="rebase on %s before testing" % samba_master,
413 default=False, action='store_true')
414 parser.add_option("", "--pushto", help="push to a git url on success",
415 default=None, type='str')
416 parser.add_option("", "--push-master", help="push to %s on success" % samba_master_ssh,
417 default=False, action='store_true')
418 parser.add_option("", "--mark", help="add a Tested-By signoff before pushing",
419 default=False, action="store_true")
420 parser.add_option("", "--fix-whitespace", help="fix whitespace on rebase",
421 default=False, action="store_true")
422 parser.add_option("", "--retry", help="automatically retry if master changes",
423 default=False, action="store_true")
424 parser.add_option("", "--email", help="send email to the given address on failure",
425 type='str', default=None)
426 parser.add_option("", "--always-email", help="always send email, even on success",
427 action="store_true")
428 parser.add_option("", "--daemon", help="daemonize after initial setup",
429 action="store_true")
432 def email_failure(status, failed_task, failed_stage, failed_tag, errstr):
433 '''send an email to options.email about the failure'''
434 user = os.getenv("USER")
435 text = '''
436 Dear Developer,
438 Your autobuild failed when trying to test %s with the following error:
441 the autobuild has been abandoned. Please fix the error and resubmit.
443 A summary of the autobuild process is here:
445 http://git.samba.org/%s/samba-autobuild/autobuild.log
446 ''' % (failed_task, errstr, user)
448 if failed_task != 'rebase':
449 text += '''
450 You can see logs of the failed task here:
452 http://git.samba.org/%s/samba-autobuild/%s.stdout
453 http://git.samba.org/%s/samba-autobuild/%s.stderr
455 or you can get full logs of all tasks in this job here:
457 http://git.samba.org/%s/samba-autobuild/logs.tar.gz
459 The top commit for the tree that was built was:
463 ''' % (user, failed_tag, user, failed_tag, user, top_commit_msg)
464 msg = MIMEText(text)
465 msg['Subject'] = 'autobuild failure for task %s during %s' % (failed_task, failed_stage)
466 msg['From'] = 'autobuild@samba.org'
467 msg['To'] = options.email
469 s = smtplib.SMTP()
470 s.connect()
471 s.sendmail(msg['From'], [msg['To']], msg.as_string())
472 s.quit()
474 def email_success():
475 '''send an email to options.email about a successful build'''
476 user = os.getenv("USER")
477 text = '''
478 Dear Developer,
480 Your autobuild has succeeded.
484 if options.keeplogs:
485 text += '''
487 you can get full logs of all tasks in this job here:
489 http://git.samba.org/%s/samba-autobuild/logs.tar.gz
491 ''' % user
493 text += '''
494 The top commit for the tree that was built was:
497 ''' % top_commit_msg
499 msg = MIMEText(text)
500 msg['Subject'] = 'autobuild success'
501 msg['From'] = 'autobuild@samba.org'
502 msg['To'] = options.email
504 s = smtplib.SMTP()
505 s.connect()
506 s.sendmail(msg['From'], [msg['To']], msg.as_string())
507 s.quit()
510 (options, args) = parser.parse_args()
512 if options.retry:
513 if not options.rebase_master and options.rebase is None:
514 raise Exception('You can only use --retry if you also rebase')
516 testbase = "%s/b%u" % (options.testbase, os.getpid())
517 test_master = "%s/master" % testbase
519 gitroot = find_git_root()
520 if gitroot is None:
521 raise Exception("Failed to find git root")
523 # get the top commit message, for emails
524 top_commit_msg = run_cmd("git log -1", dir=gitroot, output=True)
526 try:
527 os.makedirs(testbase)
528 except Exception, reason:
529 raise Exception("Unable to create %s : %s" % (testbase, reason))
530 cleanup_list.append(testbase)
532 if options.daemon:
533 logfile = os.path.join(testbase, "log")
534 print "Forking into the background, writing progress to %s" % logfile
535 daemonize(logfile)
537 write_pidfile(gitroot + "/autobuild.pid")
539 while True:
540 try:
541 run_cmd("rm -rf %s" % test_master)
542 cleanup_list.append(test_master)
543 run_cmd("git clone --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)
544 except Exception:
545 cleanup()
546 raise
548 try:
549 try:
550 if options.rebase is not None:
551 rebase_tree(options.rebase)
552 elif options.rebase_master:
553 rebase_tree(samba_master)
554 except Exception:
555 cleanup_list.append(gitroot + "/autobuild.pid")
556 cleanup()
557 email_failure(-1, 'rebase', 'rebase', 'rebase', 'rebase on master failed')
558 sys.exit(1)
559 blist = buildlist(tasks, args)
560 if options.tail:
561 blist.start_tail()
562 (status, failed_task, failed_stage, failed_tag, errstr) = blist.run()
563 if status != 0 or errstr != "retry":
564 break
565 cleanup()
566 except Exception:
567 cleanup()
568 raise
570 cleanup_list.append(gitroot + "/autobuild.pid")
572 blist.kill_kids()
573 if options.tail:
574 print("waiting for tail to flush")
575 time.sleep(1)
577 if status == 0:
578 print errstr
579 if options.passcmd is not None:
580 print("Running passcmd: %s" % options.passcmd)
581 run_cmd(options.passcmd, dir=test_master)
582 if options.pushto is not None:
583 push_to(options.pushto)
584 elif options.push_master:
585 push_to(samba_master_ssh)
586 if options.keeplogs:
587 blist.tarlogs("logs.tar.gz")
588 print("Logs in logs.tar.gz")
589 if options.always_email:
590 email_success()
591 blist.remove_logs()
592 cleanup()
593 print(errstr)
594 sys.exit(0)
596 # something failed, gather a tar of the logs
597 blist.tarlogs("logs.tar.gz")
599 if options.email is not None:
600 email_failure(status, failed_task, failed_stage, failed_tag, errstr)
602 cleanup()
603 print(errstr)
604 print("Logs in logs.tar.gz")
605 sys.exit(status)