#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 db_add_build_result(con, build_id, start, end):
+def db_add_build_result(con, build_id, start, end, successful):
cur = con.cursor()
cur.execute("SAVEPOINT a")
try:
- cur.execute("INSERT INTO jenkins_build_result(jenkins_build_id, build_start, build_end, successful) VALUES(%s, '%s', '%s', %s) RETURNING id" % (build_id, start, end, 'true'))
+ cur.execute("INSERT INTO jenkins_build_result(jenkins_build_id, build_start, build_end, successful) VALUES(%s, to_timestamp('%s'), to_timestamp('%s'), %s) RETURNING id" % (build_id, start, end, successful))
except psycopg2.DatabaseError as e:
cur.execute("ROLLBACK TO a") # have to rollback after failed command
- #logger.debug("INSERT INTO jenkins_build_result(jenkins_build_id, build_start, build_end, successful) VALUES(%s, '%s', '%s', %s) RETURNING id" % (build_id, start, end, 'true'))
+ logger.debug("INSERT INTO jenkins_build_result(jenkins_build_id, build_start, build_end, successful) VALUES(%s, '%s', '%s', %s) RETURNING id" % (build_id, start, end, successful))
return cur.fetchone()[0]
def db_add_origin(con, origin):
logger.debug("INSERT success job %s" % job_name)
# maybe FIXME: we could add the build already once its started, but for package builds we dont wanna add failures to the db at all
db_build_id = db_add_build (con, build_number, db_job_id)
- db_build_result_id = db_add_build_result (con, db_build_id, start, end)
+ db_build_result_id = db_add_build_result (con, db_build_id, start, end, 'true')
logger.debug("INSERT success build number %s" % build_number)
logger.debug("processing %s" %(changes_file))
cmd = ["dcmd", '--deb', changes_file]
return False
if cur.fetchone():
return True
+
+def get_liveboot_build_id(job_name, build_number):
+ con = db_connect()
+ cur = con.cursor()
+ try:
+ cur.execute("SELECT jenkins_build.id FROM jenkins_build"
+ " JOIN jenkins_job ON (jenkins_job.id = jenkins_build.jenkins_job_id)"
+ " WHERE jenkins_job.name = '%s' AND jenkins_build.jenkins_build_number = '%s'" % (job_name, build_number))
+ except psycopg2.DatabaseError as e:
+ logger.debug("SELECT jenkins_build.id FROM jenkins_build"
+ " JOIN jenkins_job ON (jenkins_job.id = jenkins_build.jenkins_job_id)"
+ " WHERE jenkins_job.name = '%s' AND jenkins_build.jenkins_build_number = '%s'" % (job_name, build_number))
+ return False
+ return cur.fetchone()[0]
+
+def add_liveboot_build(job_name, build_number):
+ con = db_connect()
+ db_job_id = db_add_job(con, job_name)
+ db_build_id = db_add_build (con, build_number, db_job_id)
+ con.commit()
+ logger.info("CIDB init for liveboot OK.")
+ return db_build_id
+
+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')
+ con.commit()
+ logger.info("CIDB update for liveboot OK.")
+ return db_build_result_id
+