From: Fabian Holler Date: Wed, 10 Oct 2012 13:40:14 +0000 (+0200) Subject: liveboot builds are triggered, if the pkg is in the default pkg list X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=58ef097aee90c5d769b252355a7d94dfa3289cc2;p=profitbricks%2Fjenkins-build-scripts.git liveboot builds are triggered, if the pkg is in the default pkg list --- diff --git a/add_liveboot_request.py b/add_liveboot_request.py index 7adf175..e8e496d 100644 --- a/add_liveboot_request.py +++ b/add_liveboot_request.py @@ -9,9 +9,10 @@ __author__ = "Fabian Holler " 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:]) +