summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs/modules/properties.py
diff options
context:
space:
mode:
authorYolande Amate <yolandeamate@gmail.com>2017-06-23 03:05:56 +0100
committerYolande Amate <yolandeamate@gmail.com>2017-07-05 18:24:07 +0100
commit1e41803bad17be4fc0fcf03a0f9201dbe1f0381b (patch)
tree2bd8c010dff3a664abf6ce872c57b95394e9bb28 /jenkins_jobs/modules/properties.py
parentde631d49d3505597d65fb18785a2e65fcfde9211 (diff)
downloadpython-jenkins-job-builder-1e41803bad17be4fc0fcf03a0f9201dbe1f0381b.tar.gz
python-jenkins-job-builder-1e41803bad17be4fc0fcf03a0f9201dbe1f0381b.tar.xz
python-jenkins-job-builder-1e41803bad17be4fc0fcf03a0f9201dbe1f0381b.zip
Update slave_utilization use of convert_mapping_to_xml()
Change-Id: Ifa489ad11f5825b254dd8602cdbd1ff0014736a4
Diffstat (limited to 'jenkins_jobs/modules/properties.py')
-rw-r--r--jenkins_jobs/modules/properties.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py
index 8eee680f..44366d27 100644
--- a/jenkins_jobs/modules/properties.py
+++ b/jenkins_jobs/modules/properties.py
@@ -642,13 +642,16 @@ def slave_utilization(registry, xml_parent, data):
"""
utilization = XML.SubElement(
xml_parent, 'com.suryagaddipati.jenkins.SlaveUtilizationProperty')
+
percent = int(data.get('slave-percentage', 0))
- XML.SubElement(utilization, 'needsExclusiveAccessToNode'
- ).text = 'true' if percent else 'false'
- XML.SubElement(utilization, 'slaveUtilizationPercentage'
- ).text = str(percent)
- XML.SubElement(utilization, 'singleInstancePerSlave').text = str(
- data.get('single-instance-per-slave', False)).lower()
+ exclusive_node_access = True if percent else False
+
+ mapping = [
+ ('', 'needsExclusiveAccessToNode', exclusive_node_access),
+ ('', 'slaveUtilizationPercentage', percent),
+ ('single-instance-per-slave', 'singleInstancePerSlave', False)]
+ helpers.convert_mapping_to_xml(
+ utilization, data, mapping, fail_required=True)
def delivery_pipeline(registry, xml_parent, data):