diff options
Diffstat (limited to 'jenkins_jobs/modules/helpers.py')
-rw-r--r-- | jenkins_jobs/modules/helpers.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/helpers.py b/jenkins_jobs/modules/helpers.py index 10945c71..258b13cb 100644 --- a/jenkins_jobs/modules/helpers.py +++ b/jenkins_jobs/modules/helpers.py @@ -19,6 +19,7 @@ import xml.etree.ElementTree as XML from jenkins_jobs.errors import InvalidAttributeError from jenkins_jobs.errors import JenkinsJobsException from jenkins_jobs.errors import MissingAttributeError +from jenkins_jobs.modules import hudson_model def build_trends_publisher(plugin_name, xml_element, data): @@ -613,6 +614,26 @@ def trigger_project(tconfigs, project_def, param_order=None): ) +def trigger_threshold( + parent_element, element_name, threshold_name, supported_thresholds=None +): + """Generate a resultThreshold XML element for build/join triggers""" + element = XML.SubElement(parent_element, element_name) + + try: + threshold = hudson_model.THRESHOLDS[threshold_name.upper()] + except KeyError: + if not supported_thresholds: + supported_thresholds = hudson_model.THRESHOLDS.keys() + raise JenkinsJobsException( + "threshold must be one of %s" % ", ".join(supported_thresholds) + ) + XML.SubElement(element, "name").text = threshold["name"] + XML.SubElement(element, "ordinal").text = threshold["ordinal"] + XML.SubElement(element, "color").text = threshold["color"] + return element + + def convert_mapping_to_xml(parent, data, mapping, fail_required=True): """Convert mapping to XML |