Merge "Refactor ivy function in triggers.py to utilize convert_mapping_to_xml"

This commit is contained in:
Zuul 2018-07-13 14:51:48 +00:00 committed by Gerrit Code Review
commit 5a1150b65a
2 changed files with 16 additions and 18 deletions

View File

@ -1727,23 +1727,21 @@ def ivy(registry, xml_parent, data):
"""
it = XML.SubElement(xml_parent,
'org.jenkinsci.plugins.ivytrigger.IvyTrigger')
mappings = [('path', 'ivyPath', None),
('settings-path', 'ivySettingsPath', None),
('properties-file', 'propertiesFilePath', None),
('properties-content', 'propertiesContent', None),
('debug', 'debug', False),
('download-artifacts', 'downloadArtifacts', True),
('enable-concurrent', 'enableConcurrentBuild', False),
('cron', 'spec', '')]
for prop in mappings:
opt, xmlopt, default_val = prop[:3]
val = data.get(opt, default_val)
if val is not None:
if type(val) == bool:
val = str(val).lower()
if type(val) == list:
val = ";".join(val)
XML.SubElement(it, xmlopt).text = val
mapping = [
('path', 'ivyPath', None),
('settings-path', 'ivySettingsPath', None),
('properties-content', 'propertiesContent', None),
('debug', 'debug', False),
('download-artifacts', 'downloadArtifacts', True),
('enable-concurrent', 'enableConcurrentBuild', False),
('cron', 'spec', ''),
]
convert_mapping_to_xml(it, data, mapping, fail_required=False)
properties_file_path = data.get('properties-file', [])
XML.SubElement(it, 'propertiesFilePath').text = ";".join(
properties_file_path)
label = data.get('label')
XML.SubElement(it, 'labelRestriction').text = str(bool(label)).lower()
if label:

View File

@ -4,11 +4,11 @@
<org.jenkinsci.plugins.ivytrigger.IvyTrigger>
<ivyPath>path/to/file</ivyPath>
<ivySettingsPath>path/to/settings/file</ivySettingsPath>
<propertiesFilePath>filename1;filename2</propertiesFilePath>
<debug>true</debug>
<downloadArtifacts>true</downloadArtifacts>
<enableConcurrentBuild>false</enableConcurrentBuild>
<spec>H/15 * * * *</spec>
<propertiesFilePath>filename1;filename2</propertiesFilePath>
<labelRestriction>true</labelRestriction>
<triggerLabel>master</triggerLabel>
</org.jenkinsci.plugins.ivytrigger.IvyTrigger>