Add support to customize trigger-builds block thresholds
Updated trigger-builds function to support customization of thresholds sub sections under block section Currently JJB only set default values to those three block thresholds. There are sometimes need to set different values than default. Change-Id: I73e7f828c6b651b87e7068d3c16362f4901ba32a
This commit is contained in:
parent
9cbba31054
commit
d76fa3da74
@ -298,6 +298,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
|
||||
@ -484,29 +494,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.")
|
||||
|
@ -21,16 +21,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -21,16 +21,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -21,16 +21,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -21,16 +21,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -25,16 +25,19 @@ HELLO=WORLD
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -23,16 +23,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -20,16 +20,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -20,16 +20,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -43,16 +43,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -20,16 +20,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -19,16 +19,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -19,16 +19,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
@ -19,16 +19,19 @@
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<unstableThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</unstableThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
|
35
tests/builders/fixtures/trigger-builds005.xml
Normal file
35
tests/builders/fixtures/trigger-builds005.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
<configs>
|
||||
<hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<propertiesFile>propfile.txt</propertiesFile>
|
||||
<failTriggerOnMissing>true</failTriggerOnMissing>
|
||||
</hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
</configs>
|
||||
<projects>build_started</projects>
|
||||
<condition>ALWAYS</condition>
|
||||
<triggerWithNoParameters>false</triggerWithNoParameters>
|
||||
<buildAllNodesWithLabel>false</buildAllNodesWithLabel>
|
||||
<block>
|
||||
<buildStepFailureThreshold>
|
||||
<name>UNSTABLE</name>
|
||||
<ordinal>1</ordinal>
|
||||
<color>YELLOW</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</buildStepFailureThreshold>
|
||||
<failureThreshold>
|
||||
<name>FAILURE</name>
|
||||
<ordinal>2</ordinal>
|
||||
<color>RED</color>
|
||||
<completeBuild>true</completeBuild>
|
||||
</failureThreshold>
|
||||
</block>
|
||||
</hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig>
|
||||
</configs>
|
||||
</hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
</builders>
|
||||
</project>
|
9
tests/builders/fixtures/trigger-builds005.yaml
Normal file
9
tests/builders/fixtures/trigger-builds005.yaml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user