from cidb import *
from common_code import *
-import sys
import psycopg2
import pwd
+import sys
+import urllib2
logger = logger_init()
""" Inserts a new record in the liveboot_request table. """
cur = con.cursor()
cur.execute("INSERT INTO liveboot_request(owner_uid, package_list_id)"
- " VALUES(%s, %s)", (owner_uid, package_list_id))
+ " VALUES(%s, %s) RETURNING id", (owner_uid, package_list_id))
+ result = cur.fetchone()
+ return result[0]
+def trigger_jenkins_build(request_id):
+ urllib2.urlopen("http://jenkins/view/_Tests/job/liveboot/"
+ "buildWithParameters?token=BuildIt&" + str(request_id)).read()
+ logger.info("Jenkins build triggered")
def add_liveboot_request(deb_pkg_instance_ids):
""" Creates a new liveboot request.
" unspecified")
jenkins_uid = None
- insert_liveboot_request(con, jenkins_uid, def_pkg_list_id)
+ request_id = insert_liveboot_request(con, jenkins_uid, def_pkg_list_id)
con.commit()
logger.info("New liveboot request created sucessfully")
+ trigger_jenkins_build(request_id)
+
else:
logger.info("Package isn't in the default package_list, no liveboot"
" request was created")
if __name__ == "__main__":
add_liveboot_request(sys.argv[1:])
+