cur.execute("SAVEPOINT a")
try:
cur.execute("INSERT INTO jenkins_job(name) VALUES('%s') RETURNING id" % (name))
+ con.commit()
except psycopg2.DatabaseError as e:
# record already exist
cur.execute("ROLLBACK TO a") # have to rollback after failed command
cur.execute("SELECT id FROM jenkins_job WHERE name='%s'" % (name))
#logger.debug("INSERT INTO jenkins_job(name) VALUES('%s')" % (name))
- con.commit()
return cur.fetchone()[0]
def db_add_build(con, db_id, number, start, end, status):
cur = con.cursor()
cur.execute("SAVEPOINT a")
+ if start != 'NULL':
+ start = "to_timestamp('%s')" % start
+ if end != 'NULL':
+ end = "to_timestamp('%s')" % end
try:
- cur.execute("INSERT INTO jenkins_build(jenkins_job_id, jenkins_build_number, build_start, build_end, status) VALUES(%s, %s, to_timestamp('%s'), to_timestamp('%s'), '%s') RETURNING id" % (db_id, number, start, end, status))
+ cur.execute("INSERT INTO jenkins_build(jenkins_job_id, jenkins_build_number, build_start, build_end, status) VALUES(%s, %s, %s, %s, '%s') RETURNING id" % (db_id, number, start, end, status))
+ con.commit()
except psycopg2.DatabaseError as e:
cur.execute("ROLLBACK TO a") # have to rollback after failed command
- logger.debug("INSERT INTO jenkins_build(jenkins_job_id, jenkins_build_number, build_start, build_end, status) VALUES(%s, %s, to_timestamp('%s'), to_timestamp('%s'), '%s') RETURNING id" % (db_id, number, start, end, status))
+ logger.debug("INSERT INTO jenkins_build(jenkins_job_id, jenkins_build_number, build_start, build_end, status) VALUES(%s, %s, %s, %s, '%s') RETURNING id" % (db_id, number, start, end, status))
return cur.fetchone()[0]
def db_update_build(con, db_id, end, status):
cur.execute("SAVEPOINT a")
try:
cur.execute("UPDATE jenkins_build SET build_end = '%s', status = '%s' WHERE id = %s RETURNING id" % (db_id, end, status))
+ con.commit()
except psycopg2.DatabaseError as e:
cur.execute("ROLLBACK TO a") # have to rollback after failed command
logger.debug("UPDATE jenkins_build SET build_end = '%s', status = '%s' WHERE id = %s RETURNING id" % (db_id, end, status))
cur.execute("SAVEPOINT a")
try:
cur.execute("INSERT INTO deb_package_origin(origin) VALUES('%s') RETURNING id" % (origin))
- except psycopg2.DatabaseError as e:
+ con.commit()
+ except psycopg2.DatabaseError as e:
# record already exist
cur.execute("ROLLBACK TO a") # have to rollback after failed command
cur.execute("SELECT id FROM deb_package_origin WHERE origin='%s'" % (origin))
cur.execute("SAVEPOINT a")
try:
cur.execute("INSERT INTO deb_package(name) VALUES('%s') RETURNING id" % (package))
+ con.commit()
except psycopg2.DatabaseError as e:
# record already exist
cur.execute("ROLLBACK TO a") # have to rollback after failed command
cur.execute("SAVEPOINT a")
try:
cur.execute("INSERT INTO deb_package_instance(deb_package_id, deb_package_origin_id, jenkins_build_id, version, available) VALUES(%s, %s, %s, '%s', true) RETURNING id" % (package_id, origin_id, build_id, version))
+ con.commit()
except psycopg2.DatabaseError as e:
# record already exist - this MUST NOT HAPPEN for jenkins builds
cur.execute("ROLLBACK TO a") # have to rollback after failed command
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))
+ con.commit()
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))