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

View File

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

View File

@ -1,6 +1,6 @@
publishers: publishers:
- build-publisher: - build-publisher:
publish-unstable-builds: true publish-unstable-builds: false
publish-failed-builds: true publish-failed-builds: false
days-to-keep: -1 days-to-keep: -1
num-to-keep: 100 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