logger.info("CIDB init for liveboot OK.")
return
-def finish_liveboot_build(build_id, end):
+def finish_liveboot_build(build_id, end, status):
con = db_connect()
- db_update_build(con, build_id, end, 'successful')
+ db_update_build(con, build_id, end, status)
con.commit()
logger.info("CIDB update for liveboot OK.")
return
if __name__ == '__main__':
- if len(sys.argv) != 5 and len(sys.argv) !=6:
+ if len(sys.argv) != 5 and len(sys.argv) !=7:
# if the build was just started:
print("usage: %s $job_name $build_number $liveboot_request_id $start_time")
print("or:")
# if the build was successful
- print("usage: %s $job_name $build_number $liveboot_request_id $start_time $end_time")
+ print("usage: %s $job_name $build_number $liveboot_request_id $start_time $end_time $status")
sys.exit(1)
job_name = sys.argv[1]
request_id = sys.argv[3]
start = sys.argv[4]
- if len(sys.argv) != 6:
+ if len(sys.argv) != 7:
add_liveboot_build(job_name, build_number, request_id, start)
else:
end = sys.argv[5]
+ status = sys.argv[6]
build_id = get_liveboot_build_id(job_name, build_number)
- finish_liveboot_build(build_id, end)
+ finish_liveboot_build(build_id, end, status)
# copyright 2012 Holger Levsen <holger@layer-acht.org>
# GPL2 licenced
+set_failure() {
+ BUILD_END=$(date +%s)
+ $SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $REQUEST_ID $BUILD_START $BUILD_END "failed"
+ exit 1
+}
+
set -e
#set -x
export
BUILD_START=$(date +%s)
$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $REQUEST_ID $BUILD_START
+#
+# trap failures
+#
+trap set_failure INT TERM EXIT
+
#
# build liveboot
#
# add liveboot build result to cidb
#
BUILD_END=$(date +%s)
-$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $REQUEST_ID $BUILD_START $BUILD_END
+$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $REQUEST_ID $BUILD_START $BUILD_END "successful"
# FIXME: too much sudo here...
cd /srv/build/liveboot/builds
du -sh /srv/mirror/liveboot
figlet "OK"
+
+#
+# remove trap to not set failure at the end :)
+#
+trap - INT TERM EXIT