summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-13 14:51:48 +0000
committerGerrit Code Review <review@openstack.org>2018-07-13 14:51:49 +0000
commit5a1150b65ad40ab46edee2f711c4e28b9cea0b45 (patch)
tree5fd0821a9dfed08caba89ef5da09c0564b5a8513
parent6123a7e555c6c23c977075c6460aac0b8b5a15b6 (diff)
parentf7d5ef5617729ec54c54cb5de3af477d6b8236cf (diff)
Merge "Refactor ivy function in triggers.py to utilize convert_mapping_to_xml"
-rw-r--r--jenkins_jobs/modules/triggers.py32
-rw-r--r--tests/triggers/fixtures/ivy.xml2
2 files changed, 16 insertions, 18 deletions
diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py
index cf7db98..a888b8f 100644
--- a/jenkins_jobs/modules/triggers.py
+++ b/jenkins_jobs/modules/triggers.py
@@ -1727,23 +1727,21 @@ def ivy(registry, xml_parent, data):
1727 """ 1727 """
1728 it = XML.SubElement(xml_parent, 1728 it = XML.SubElement(xml_parent,
1729 'org.jenkinsci.plugins.ivytrigger.IvyTrigger') 1729 'org.jenkinsci.plugins.ivytrigger.IvyTrigger')
1730 mappings = [('path', 'ivyPath', None), 1730 mapping = [
1731 ('settings-path', 'ivySettingsPath', None), 1731 ('path', 'ivyPath', None),
1732 ('properties-file', 'propertiesFilePath', None), 1732 ('settings-path', 'ivySettingsPath', None),
1733 ('properties-content', 'propertiesContent', None), 1733 ('properties-content', 'propertiesContent', None),
1734 ('debug', 'debug', False), 1734 ('debug', 'debug', False),
1735 ('download-artifacts', 'downloadArtifacts', True), 1735 ('download-artifacts', 'downloadArtifacts', True),
1736 ('enable-concurrent', 'enableConcurrentBuild', False), 1736 ('enable-concurrent', 'enableConcurrentBuild', False),
1737 ('cron', 'spec', '')] 1737 ('cron', 'spec', ''),
1738 for prop in mappings: 1738 ]
1739 opt, xmlopt, default_val = prop[:3] 1739 convert_mapping_to_xml(it, data, mapping, fail_required=False)
1740 val = data.get(opt, default_val) 1740
1741 if val is not None: 1741 properties_file_path = data.get('properties-file', [])
1742 if type(val) == bool: 1742 XML.SubElement(it, 'propertiesFilePath').text = ";".join(
1743 val = str(val).lower() 1743 properties_file_path)
1744 if type(val) == list: 1744
1745 val = ";".join(val)
1746 XML.SubElement(it, xmlopt).text = val
1747 label = data.get('label') 1745 label = data.get('label')
1748 XML.SubElement(it, 'labelRestriction').text = str(bool(label)).lower() 1746 XML.SubElement(it, 'labelRestriction').text = str(bool(label)).lower()
1749 if label: 1747 if label:
diff --git a/tests/triggers/fixtures/ivy.xml b/tests/triggers/fixtures/ivy.xml
index ae37a1c..47a8651 100644
--- a/tests/triggers/fixtures/ivy.xml
+++ b/tests/triggers/fixtures/ivy.xml
@@ -4,11 +4,11 @@
4 <org.jenkinsci.plugins.ivytrigger.IvyTrigger> 4 <org.jenkinsci.plugins.ivytrigger.IvyTrigger>
5 <ivyPath>path/to/file</ivyPath> 5 <ivyPath>path/to/file</ivyPath>
6 <ivySettingsPath>path/to/settings/file</ivySettingsPath> 6 <ivySettingsPath>path/to/settings/file</ivySettingsPath>
7 <propertiesFilePath>filename1;filename2</propertiesFilePath>
8 <debug>true</debug> 7 <debug>true</debug>
9 <downloadArtifacts>true</downloadArtifacts> 8 <downloadArtifacts>true</downloadArtifacts>
10 <enableConcurrentBuild>false</enableConcurrentBuild> 9 <enableConcurrentBuild>false</enableConcurrentBuild>
11 <spec>H/15 * * * *</spec> 10 <spec>H/15 * * * *</spec>
11 <propertiesFilePath>filename1;filename2</propertiesFilePath>
12 <labelRestriction>true</labelRestriction> 12 <labelRestriction>true</labelRestriction>
13 <triggerLabel>master</triggerLabel> 13 <triggerLabel>master</triggerLabel>
14 </org.jenkinsci.plugins.ivytrigger.IvyTrigger> 14 </org.jenkinsci.plugins.ivytrigger.IvyTrigger>