]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
liveboot builds are triggered, if the pkg is in the default pkg list
authorFabian Holler <fabian.holler@profitbricks.com>
Wed, 10 Oct 2012 13:40:14 +0000 (15:40 +0200)
committerFabian Holler <fabian.holler@profitbricks.com>
Wed, 10 Oct 2012 13:40:14 +0000 (15:40 +0200)
add_liveboot_request.py

index 7adf175ac768f7c267df2fb480e6a26e9965f2e3..e8e496d2e791e447b9fc9424669b8f64ab6be4cf 100644 (file)
@@ -9,9 +9,10 @@ __author__ = "Fabian Holler <fabian.holler@profitbricks.com>"
 
 from cidb import *
 from common_code import *
-import sys
 import psycopg2
 import pwd
+import sys
+import urllib2
 
 logger = logger_init()
 
@@ -120,8 +121,14 @@ def insert_liveboot_request(con, owner_uid, package_list_id):
     """ 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.
@@ -177,9 +184,11 @@ def add_liveboot_request(deb_pkg_instance_ids):
             " 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")
@@ -187,3 +196,4 @@ def add_liveboot_request(deb_pkg_instance_ids):
 
 if __name__ == "__main__":
     add_liveboot_request(sys.argv[1:])
+