diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py
index fea1c14ad..c162df0d5 100644
--- a/jenkins_jobs/modules/builders.py
+++ b/jenkins_jobs/modules/builders.py
@@ -297,6 +297,16 @@ def trigger_builds(parser, xml_parent, data):
to the triggered job
:arg bool block: whether to wait for the triggered jobs
to finish or not (default false)
+ :arg dict block-thresholds: Fail builds and/or mark as failed or unstable
+ based on thresholds. Only apply if block parameter is true (optional)
+
+ * **build-step-failure-threshold** (`str`)
+ ['never', 'SUCCESS', 'UNSTABLE', 'FAILURE'] (default: 'FAILURE')
+ * **unstable-threshold** (`str`)
+ ['never', 'SUCCESS', 'UNSTABLE', 'FAILURE'] (default: 'UNSTABLE')
+ * **failure-threshold** (`str`)
+ ['never', 'SUCCESS', 'UNSTABLE', 'FAILURE'] (default: 'FAILURE')
+
:arg bool same-node: Use the same node for the triggered builds that was
used for this build (optional)
:arg list parameter-factories: list of parameter factories
@@ -483,29 +493,40 @@ def trigger_builds(parser, xml_parent, data):
'buildAllNodesWithLabel')
build_all_nodes_with_label.text = 'false'
block = project_def.get('block', False)
- if(block):
+ if block:
block = XML.SubElement(tconfig, 'block')
- bsft = XML.SubElement(block, 'buildStepFailureThreshold')
- XML.SubElement(bsft, 'name').text = \
- hudson_model.FAILURE['name']
- XML.SubElement(bsft, 'ordinal').text = \
- hudson_model.FAILURE['ordinal']
- XML.SubElement(bsft, 'color').text = \
- hudson_model.FAILURE['color']
- ut = XML.SubElement(block, 'unstableThreshold')
- XML.SubElement(ut, 'name').text = \
- hudson_model.UNSTABLE['name']
- XML.SubElement(ut, 'ordinal').text = \
- hudson_model.UNSTABLE['ordinal']
- XML.SubElement(ut, 'color').text = \
- hudson_model.UNSTABLE['color']
- ft = XML.SubElement(block, 'failureThreshold')
- XML.SubElement(ft, 'name').text = \
- hudson_model.FAILURE['name']
- XML.SubElement(ft, 'ordinal').text = \
- hudson_model.FAILURE['ordinal']
- XML.SubElement(ft, 'color').text = \
- hudson_model.FAILURE['color']
+ supported_thresholds = [['build-step-failure-threshold',
+ 'buildStepFailureThreshold',
+ 'FAILURE'],
+ ['unstable-threshold',
+ 'unstableThreshold',
+ 'UNSTABLE'],
+ ['failure-threshold',
+ 'failureThreshold',
+ 'FAILURE']]
+ supported_threshold_values = ['never',
+ hudson_model.SUCCESS['name'],
+ hudson_model.UNSTABLE['name'],
+ hudson_model.FAILURE['name']]
+ thrsh = project_def.get('block-thresholds', False)
+ for toptname, txmltag, tvalue in supported_thresholds:
+ if thrsh:
+ tvalue = thrsh.get(toptname, tvalue)
+ if tvalue.lower() == supported_threshold_values[0]:
+ continue
+ if tvalue.upper() not in supported_threshold_values:
+ raise JenkinsJobsException(
+ "threshold value must be one of (%s)" %
+ ", ".join(supported_threshold_values))
+ th = XML.SubElement(block, txmltag)
+ XML.SubElement(th, 'name').text = hudson_model.THRESHOLDS[
+ tvalue.upper()]['name']
+ XML.SubElement(th, 'ordinal').text = hudson_model.THRESHOLDS[
+ tvalue.upper()]['ordinal']
+ XML.SubElement(th, 'color').text = hudson_model.THRESHOLDS[
+ tvalue.upper()]['color']
+ XML.SubElement(th, 'completeBuild').text = "true"
+
# If configs is empty, remove the entire tbuilder tree.
if(len(configs) == 0):
logger.debug("Pruning empty TriggerBuilder tree.")
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel-optionals.xml b/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel-optionals.xml
index f8300bcc3..58421c85a 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel-optionals.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel-optionals.xml
@@ -21,16 +21,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel.xml b/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel.xml
index ac17062d3..a5c42c80d 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-allnodesforlabel.xml
@@ -21,16 +21,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-binaryfile-optionals.xml b/tests/builders/fixtures/trigger-builds-configfactory-binaryfile-optionals.xml
index 278801a4b..58c6e2e8e 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-binaryfile-optionals.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-binaryfile-optionals.xml
@@ -21,16 +21,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-binaryfile.xml b/tests/builders/fixtures/trigger-builds-configfactory-binaryfile.xml
index 8858373bc..1f8304401 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-binaryfile.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-binaryfile.xml
@@ -21,16 +21,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-counterbuild-optionals.xml b/tests/builders/fixtures/trigger-builds-configfactory-counterbuild-optionals.xml
index 985d15dc4..450b799bc 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-counterbuild-optionals.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-counterbuild-optionals.xml
@@ -25,16 +25,19 @@ HELLO=WORLD
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-counterbuild.xml b/tests/builders/fixtures/trigger-builds-configfactory-counterbuild.xml
index 07ffe060f..b7acb65d5 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-counterbuild.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-counterbuild.xml
@@ -23,16 +23,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-filebuild-optionals.xml b/tests/builders/fixtures/trigger-builds-configfactory-filebuild-optionals.xml
index b089e1951..9974900e3 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-filebuild-optionals.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-filebuild-optionals.xml
@@ -20,16 +20,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-filebuild.xml b/tests/builders/fixtures/trigger-builds-configfactory-filebuild.xml
index 5fe8083c1..41698e285 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-filebuild.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-filebuild.xml
@@ -20,16 +20,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds-configfactory-multi.xml b/tests/builders/fixtures/trigger-builds-configfactory-multi.xml
index d95c04b3a..2f272b44b 100644
--- a/tests/builders/fixtures/trigger-builds-configfactory-multi.xml
+++ b/tests/builders/fixtures/trigger-builds-configfactory-multi.xml
@@ -43,16 +43,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds001.xml b/tests/builders/fixtures/trigger-builds001.xml
index 13161d124..4331e4bfe 100644
--- a/tests/builders/fixtures/trigger-builds001.xml
+++ b/tests/builders/fixtures/trigger-builds001.xml
@@ -20,16 +20,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds002.xml b/tests/builders/fixtures/trigger-builds002.xml
index 63b7caa80..b5bed7159 100644
--- a/tests/builders/fixtures/trigger-builds002.xml
+++ b/tests/builders/fixtures/trigger-builds002.xml
@@ -19,16 +19,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds003.xml b/tests/builders/fixtures/trigger-builds003.xml
index ac5b77524..74278e3c3 100644
--- a/tests/builders/fixtures/trigger-builds003.xml
+++ b/tests/builders/fixtures/trigger-builds003.xml
@@ -19,16 +19,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds004.xml b/tests/builders/fixtures/trigger-builds004.xml
index 0e23bab5e..f75941986 100644
--- a/tests/builders/fixtures/trigger-builds004.xml
+++ b/tests/builders/fixtures/trigger-builds004.xml
@@ -19,16 +19,19 @@
FAILURE
2
RED
+ true
UNSTABLE
1
YELLOW
+ true
FAILURE
2
RED
+ true
diff --git a/tests/builders/fixtures/trigger-builds005.xml b/tests/builders/fixtures/trigger-builds005.xml
new file mode 100644
index 000000000..f950214b4
--- /dev/null
+++ b/tests/builders/fixtures/trigger-builds005.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+ propfile.txt
+ true
+
+
+ build_started
+ ALWAYS
+ false
+ false
+
+
+ UNSTABLE
+ 1
+ YELLOW
+ true
+
+
+ FAILURE
+ 2
+ RED
+ true
+
+
+
+
+
+
+
diff --git a/tests/builders/fixtures/trigger-builds005.yaml b/tests/builders/fixtures/trigger-builds005.yaml
new file mode 100644
index 000000000..aa792fc59
--- /dev/null
+++ b/tests/builders/fixtures/trigger-builds005.yaml
@@ -0,0 +1,9 @@
+builders:
+ - trigger-builds:
+ - project: "build_started"
+ property-file: propfile.txt
+ block: true
+ block-thresholds:
+ build-step-failure-threshold: UNSTABLE
+ unstable-threshold: never
+ failure-threshold: FAILURE