def db_add_build(con, db_id, number, start, end, status):
cur = con.cursor()
cur.execute("SAVEPOINT a")
- if start != 'NULL':
+ if start != 'NULL' and start.isdigit():
start = "to_timestamp('%s')" % start
- if end != 'NULL':
+ if end != 'NULL' and end.isdigit():
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, %s, %s, '%s') RETURNING id" % (db_id, number, start, end, status))
def db_update_build(con, db_id, end, status):
cur = con.cursor()
cur.execute("SAVEPOINT a")
+ if end != 'NULL' and end.isdigit():
+ end = "to_timestamp('%s')" % end
try:
- cur.execute("UPDATE jenkins_build SET build_end = to_timestamp('%s'), status = '%s' WHERE id = %s RETURNING id" % (end, status, db_id))
+ cur.execute("UPDATE jenkins_build SET build_end = '%s', status = '%s' WHERE id = %s RETURNING id" % (end, status, db_id))
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 = to_timestamp('%s'), status = '%s' WHERE id = %s RETURNING id" % (end, status, db_id))
+ logger.debug("UPDATE jenkins_build SET build_end = '%s', status = '%s' WHERE id = %s RETURNING id" % (end, status, db_id))
return cur.fetchone()[0]
def db_add_origin(con, origin):