Merge "Update build_keeper to use convert_mapping_to_xml()"
This commit is contained in:
commit
3bb56f745e
@ -490,50 +490,43 @@ def build_keeper(registry, xml_parent, data):
|
|||||||
.. literalinclude:: /../../tests/wrappers/fixtures/build-keeper0002.yaml
|
.. literalinclude:: /../../tests/wrappers/fixtures/build-keeper0002.yaml
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
root = XML.SubElement(xml_parent,
|
root = XML.SubElement(xml_parent,
|
||||||
'org.jenkins__ci.plugins.build__keeper.BuildKeeper')
|
'org.jenkins__ci.plugins.build__keeper.BuildKeeper')
|
||||||
|
|
||||||
valid_policies = ('by-day', 'keep-since', 'build-number',
|
valid_policies = ('by-day', 'keep-since', 'build-number',
|
||||||
'keep-first-failed')
|
'keep-first-failed')
|
||||||
policy = data.get('policy')
|
policy = data.get('policy')
|
||||||
build_period = str(data.get('build-period', 0))
|
|
||||||
dont_keep_failed = str(data.get('dont-keep-failed', False)).lower()
|
mapping = [
|
||||||
|
('build-period', 'buildPeriod', 0),
|
||||||
|
('dont-keep-failed', 'dontKeepFailed', False)]
|
||||||
|
|
||||||
if policy == 'by-day':
|
if policy == 'by-day':
|
||||||
policy_element = XML.SubElement(root,
|
policy_element = XML.SubElement(root,
|
||||||
'policy',
|
'policy',
|
||||||
{'class': 'org.jenkins_ci.plugins.'
|
{'class': 'org.jenkins_ci.plugins.'
|
||||||
'build_keeper.ByDayPolicy'})
|
'build_keeper.ByDayPolicy'})
|
||||||
XML.SubElement(policy_element, 'buildPeriod').text = build_period
|
|
||||||
XML.SubElement(policy_element,
|
|
||||||
'dontKeepFailed').text = dont_keep_failed
|
|
||||||
elif policy == 'keep-since':
|
elif policy == 'keep-since':
|
||||||
policy_element = XML.SubElement(root,
|
policy_element = XML.SubElement(root,
|
||||||
'policy',
|
'policy',
|
||||||
{'class': 'org.jenkins_ci.plugins.'
|
{'class': 'org.jenkins_ci.plugins.'
|
||||||
'build_keeper.KeepSincePolicy'})
|
'build_keeper.KeepSincePolicy'})
|
||||||
XML.SubElement(policy_element, 'buildPeriod').text = build_period
|
|
||||||
XML.SubElement(policy_element,
|
|
||||||
'dontKeepFailed').text = dont_keep_failed
|
|
||||||
elif policy == 'build-number':
|
elif policy == 'build-number':
|
||||||
policy_element = XML.SubElement(root,
|
policy_element = XML.SubElement(root,
|
||||||
'policy',
|
'policy',
|
||||||
{'class': 'org.jenkins_ci.plugins.'
|
{'class': 'org.jenkins_ci.plugins.'
|
||||||
'build_keeper.BuildNumberPolicy'})
|
'build_keeper.BuildNumberPolicy'})
|
||||||
XML.SubElement(policy_element, 'buildPeriod').text = build_period
|
|
||||||
XML.SubElement(policy_element,
|
|
||||||
'dontKeepFailed').text = dont_keep_failed
|
|
||||||
elif policy == 'keep-first-failed':
|
elif policy == 'keep-first-failed':
|
||||||
policy_element = XML.SubElement(root,
|
policy_element = XML.SubElement(root,
|
||||||
'policy',
|
'policy',
|
||||||
{'class': 'org.jenkins_ci.plugins.'
|
{'class': 'org.jenkins_ci.plugins.'
|
||||||
'build_keeper.KeepFirstFailedPolicy'})
|
'build_keeper.KeepFirstFailedPolicy'})
|
||||||
XML.SubElement(policy_element, 'numberOfFails').text = str(
|
mapping = [('number-of-fails', 'numberOfFails', 0)]
|
||||||
data.get('number-of-fails', 0))
|
|
||||||
else:
|
else:
|
||||||
InvalidAttributeError('policy', policy, valid_policies)
|
InvalidAttributeError('policy', policy, valid_policies)
|
||||||
|
|
||||||
|
convert_mapping_to_xml(policy_element, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def live_screenshot(registry, xml_parent, data):
|
def live_screenshot(registry, xml_parent, data):
|
||||||
"""yaml: live-screenshot
|
"""yaml: live-screenshot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user