Update build_publisher plugin

- update build_publisher to use convert xml
- update test cases
- remove the tailing \

Change-Id: I5b63ff85108725878f48e0562e49bb3129ab8935
This commit is contained in:
Dong Ma 2017-06-24 16:07:28 +08:00
parent de631d49d3
commit 897b825900
6 changed files with 30 additions and 23 deletions

View File

@ -4372,10 +4372,16 @@ def build_publisher(registry, xml_parent, data):
:arg int num-to-keep: number of jobs to keep in the published results
(optional)
Example:
Minimal Example:
.. literalinclude::
/../../tests/publishers/fixtures/build-publisher002.yaml
/../../tests/publishers/fixtures/build-publisher-minimal.yaml
:language: yaml
Full Example:
.. literalinclude::
/../../tests/publishers/fixtures/build-publisher-full.yaml
:language: yaml
"""
@ -4383,21 +4389,24 @@ def build_publisher(registry, xml_parent, data):
xml_parent,
'hudson.plugins.build__publisher.BuildPublisher')
XML.SubElement(reporter, 'publishUnstableBuilds').text = \
str(data.get('publish-unstable-builds', True)).lower()
XML.SubElement(reporter, 'publishFailedBuilds').text = \
str(data.get('publish-failed-builds', True)).lower()
mappings = [
('publish-unstable-builds', 'publishUnstableBuilds', True),
('publish-failed-builds', 'publishFailedBuilds', True)
]
helpers.convert_mapping_to_xml(
reporter, data, mappings, fail_required=True)
if 'days-to-keep' in data or 'num-to-keep' in data:
logrotator = XML.SubElement(reporter, 'logRotator')
XML.SubElement(logrotator, 'daysToKeep').text = \
str(data.get('days-to-keep', -1))
XML.SubElement(logrotator, 'numToKeep').text = \
str(data.get('num-to-keep', -1))
# hardcoded to -1 to emulate what the build publisher
# plugin seem to do.
XML.SubElement(logrotator, 'artifactDaysToKeep').text = "-1"
XML.SubElement(logrotator, 'artifactNumToKeep').text = "-1"
mappings = [
('days-to-keep', 'daysToKeep', -1),
('num-to-keep', 'numToKeep', -1),
# hardcoded to -1 to emulate what the build publisher
# plugin seem to do.
('', 'artifactDaysToKeep', -1),
('', 'artifactNumToKeep', -1)
]
helpers.convert_mapping_to_xml(
logrotator, data, mappings, fail_required=True)
def stash(registry, xml_parent, data):

View File

@ -2,8 +2,8 @@
<project>
<publishers>
<hudson.plugins.build__publisher.BuildPublisher>
<publishUnstableBuilds>true</publishUnstableBuilds>
<publishFailedBuilds>true</publishFailedBuilds>
<publishUnstableBuilds>false</publishUnstableBuilds>
<publishFailedBuilds>false</publishFailedBuilds>
<logRotator>
<daysToKeep>-1</daysToKeep>
<numToKeep>100</numToKeep>

View File

@ -1,6 +1,6 @@
publishers:
- build-publisher:
publish-unstable-builds: true
publish-failed-builds: true
publish-unstable-builds: false
publish-failed-builds: false
days-to-keep: -1
num-to-keep: 100

View File

@ -0,0 +1,2 @@
publishers:
- build-publisher

View File

@ -1,4 +0,0 @@
publishers:
- build-publisher:
publish-unstable-builds: true
publish-failed-builds: true