]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
fixed jenkins liveboot build trigger
authorFabian Holler <fabian.holler@profitbricks.com>
Mon, 15 Oct 2012 10:06:50 +0000 (12:06 +0200)
committerHolger Levsen <holger@layer-acht.org>
Mon, 15 Oct 2012 10:10:39 +0000 (12:10 +0200)
add_liveboot_request.py

index 0773a71981f126c0f010eda458150f9c5d28e72b..6c39868e3804a6e98636991d42cd1dccc86bc6de 100644 (file)
@@ -66,7 +66,7 @@ def get_deb_pkg_instance_ids(con, deb_package_id):
         " JOIN deb_package AS dp ON (dpi.deb_package_id = dp.id)"
         " WHERE dp.id=%s", (deb_package_id,))
     result = cur.fetchall()
-    return tuple([ i[0] for i in result ])
+    return tuple([i[0] for i in result])
 
 
 def duplicate_pkg_list(con, deb_package_list_id):
@@ -125,10 +125,13 @@ def insert_liveboot_request(con, 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&REQUEST_ID=" + str(REQUEST_ID)).read()
-    logger.info("Jenkins build triggered")
+    url = "http://jenkins/view/_Tests/job/liveboot/buildWithParameters?token"
+    "=BuildIt&REQUEST_ID=" + str(request_id)
+    urllib2.urlopen(url).read()
+    logger.info("Jenkins build triggered (%s)" % url)
+
 
 def add_liveboot_request(deb_pkg_instance_ids):
     """ Creates a new liveboot request.
@@ -170,9 +173,9 @@ def add_liveboot_request(deb_pkg_instance_ids):
             logger.debug("deb_pkg_instance_id %s included in the liveboot"
                 " request" % deb_pkg_instance_id)
         else:
-            logger.debug("deb_pkg_instance_id %s isn't included in the liveboot"
-                " request because it isn't member of the default package list"
-                % deb_pkg_instance_id)
+            logger.debug("deb_pkg_instance_id %s isn't included in the"
+                    " liveboot request. It isn't listed in the default"
+                    " package list" % deb_pkg_instance_id)
 
     if def_pkg_list_updated:
         pkg_list = duplicate_pkg_list(con, def_pkg_list_id)
@@ -180,8 +183,8 @@ def add_liveboot_request(deb_pkg_instance_ids):
         try:
             jenkins_uid = pwd.getpwnam("jenkins").pw_uid
         except Exception as e:
-            logger.warning("User jenkins can't be found, liveboot_request uid is"
-            " unspecified")
+            logger.warning("User jenkins can't be found, liveboot_request uid"
+                    " is unspecified")
             jenkins_uid = None
 
         request_id = insert_liveboot_request(con, jenkins_uid, def_pkg_list_id)
@@ -196,4 +199,3 @@ def add_liveboot_request(deb_pkg_instance_ids):
 
 if __name__ == "__main__":
     add_liveboot_request(sys.argv[1:])
-