con.commit()
return db_package_instance_id
+def db_add_requested_liveboot_build (con, request_id, build_id)
+ cur = con.cursor()
+ cur.execute("SAVEPOINT a")
+ try:
+ cur.execute("INSERT INTO liveboot_request_jenkins_build(liveboot_request_id, jenkins_build_id) VALUES(%s, %s) RETURNING id" % (request_id_ build_id))
+ except psycopg2.DatabaseError as e:
+ cur.execute("ROLLBACK TO a") # have to rollback after failed command
+ #logger.debug("INSERT INTO jenkins_build(jenkins_build_number, jenkins_job_id) VALUES(%s, %s) RETURNING id" % (number, db_id))
+ return cur.fetchone()[0]
+
def get_package_instance(origin, package, version):
con = db_connect()
cur = con.cursor()
return False
return cur.fetchone()[0]
-def add_liveboot_build(job_name, build_number):
+def add_liveboot_build(job_name, build_number, request_id):
con = db_connect()
db_job_id = db_add_job(con, job_name)
db_build_id = db_add_build (con, build_number, db_job_id)
+ db_add_requested_liveboot_build (con, request_id, build_id)
con.commit()
logger.info("CIDB init for liveboot OK.")
- return db_build_id
+ return
def finish_liveboot_build(build_id, start, end):
con = db_connect()
- db_build_result_id = db_add_build_result (con, build_id, start, end, 'true')
+ db_add_build_result (con, build_id, start, end, 'true')
con.commit()
logger.info("CIDB update for liveboot OK.")
- return db_build_result_id
+ return
if __name__ == '__main__':
- if len(sys.argv) != 3 and len(sys.argv) !=5:
- print("usage: %s $packages_file $origin")
+ if len(sys.argv) != 4 and len(sys.argv) !=6:
+ # if the build was just started:
+ print("usage: %s $job_name $build_number $liveboot_request_id")
+ print("or:")
+ # if the build was successful
+ print("usage: %s $job_name $build_number $liveboot_request_id $start_time $end_time")
sys.exit(1)
job_name = sys.argv[1]
build_number = sys.argv[2]
+ request_id = sys.argv[3]
- if len(sys.argv) != 5:
- add_liveboot_build(job_name, build_number)
+ if len(sys.argv) != 6:
+ add_liveboot_build(job_name, build_number, request_id)
else:
- begin = sys.argv[3]
- end = sys.argv[4]
+ begin = sys.argv[4]
+ end = sys.argv[5]
build_id = get_liveboot_build_id(job_name, build_number)
finish_liveboot_build(build_id, begin, end)
# add liveboot build to cidb
#
BUILD_START=$(date +%s)
-$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER
+$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $REQUEST_ID
#
# build liveboot
# add liveboot build result to cidb
#
BUILD_END=$(date +%s)
-$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $BUILD_START $BUILD_END
+$SCRIPTSDIR/liveboot2db.py $JOB_NAME $BUILD_NUMBER $REQUEST_ID $BUILD_START $BUILD_END
# FIXME: too much sudo here...
cd /srv/build/liveboot/builds