From a7b7b8a30ce1383f5a9a52103344ba8b5544a12a Mon Sep 17 00:00:00 2001 From: "william.soula" Date: Wed, 7 Nov 2012 19:36:22 -0600 Subject: [PATCH] Adding ability to block build till triggered builds complete Change-Id: Ia5c386e664e52b0be568b46abeb0491c512442c3 Reviewed-on: https://review.openstack.org/15734 Reviewed-by: James E. Blair Approved: Clark Boylan Reviewed-by: Clark Boylan Tested-by: Jenkins --- jenkins_jobs/modules/builders.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index 95496d460..3306943da 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -154,6 +154,8 @@ def trigger_builds(parser, xml_parent, data): :arg str project: the Jenkins project to trigger :arg str predefined-parameters: key/value pairs to be passed to the job (optional) + :arg bool block: whether to wait for the triggered jobs + to finish or not (default false) Example:: @@ -162,6 +164,7 @@ def trigger_builds(parser, xml_parent, data): - project: "build_started" predefined-parameters: FOO="bar" + block: true """ tbuilder = XML.SubElement(xml_parent, @@ -194,6 +197,21 @@ def trigger_builds(parser, xml_parent, data): build_all_nodes_with_label = XML.SubElement(tconfig, 'buildAllNodesWithLabel') build_all_nodes_with_label.text = 'false' + block = project_def.get('block', False) + if(block): + block = XML.SubElement(tconfig, 'block') + bsft = XML.SubElement(block, 'buildStepFailureThreshold') + XML.SubElement(bsft, 'name').text = 'FAILURE' + XML.SubElement(bsft, 'ordinal').text = '2' + XML.SubElement(bsft, 'color').text = 'RED' + ut = XML.SubElement(block, 'unstableThreshold') + XML.SubElement(ut, 'name').text = 'UNSTABLE' + XML.SubElement(ut, 'ordinal').text = '1' + XML.SubElement(ut, 'color').text = 'Yellow' + ft = XML.SubElement(block, 'failureThreshold') + XML.SubElement(ft, 'name').text = 'FAILURE' + XML.SubElement(ft, 'ordinal').text = '2' + XML.SubElement(ft, 'color').text = 'RED' # If configs is empty, remove the entire tbuilder tree. if(len(configs) == 0): logger.debug("Pruning empty TriggerBuilder tree.")