From 33fc571832cfe6390040469702d58207b0683a6d Mon Sep 17 00:00:00 2001 From: Dong Ma <winterma.dong@gmail.com> Date: Mon, 5 Dec 2016 06:10:49 -0800 Subject: [PATCH] Update robot plugin - update robot plugin to convert xml - update docstring - update test cases - add plugin="robot" attribute Change-Id: I350d99beca71fcb6932491b3709ee2b6d89ca642 --- jenkins_jobs/modules/publishers.py | 43 +++++++++++-------- .../{robot001.xml => robot-complete.xml} | 3 +- .../{robot001.yaml => robot-complete.yaml} | 1 + tests/publishers/fixtures/robot-minimal.xml | 18 ++++++++ tests/publishers/fixtures/robot-minimal.yaml | 3 ++ 5 files changed, 48 insertions(+), 20 deletions(-) rename tests/publishers/fixtures/{robot001.xml => robot-complete.xml} (87%) rename tests/publishers/fixtures/{robot001.yaml => robot-complete.yaml} (93%) create mode 100644 tests/publishers/fixtures/robot-minimal.xml create mode 100644 tests/publishers/fixtures/robot-minimal.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 0e562239c..7369a791b 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3673,7 +3673,7 @@ def robot(registry, xml_parent, data): <Robot+Framework+Plugin>`. :arg str output-path: Path to directory containing robot xml and html files - relative to build workspace. (default '') + relative to build workspace. (required) :arg str log-file-link: Name of log or report file to be linked on jobs front page (default '') :arg str report-html: Name of the html file containing robot test report @@ -3691,30 +3691,35 @@ def robot(registry, xml_parent, data): :arg list other-files: list other files to archive (default '') :arg bool archive-output-xml: Archive output xml file to server (default true) + :arg bool enable-cache: Enable cache for test results (default true) - Example: + Minimal Example: - .. literalinclude:: /../../tests/publishers/fixtures/robot001.yaml + .. literalinclude:: /../../tests/publishers/fixtures/robot-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/robot-complete.yaml :language: yaml """ parent = XML.SubElement(xml_parent, 'hudson.plugins.robot.RobotPublisher') - XML.SubElement(parent, 'outputPath').text = data['output-path'] - XML.SubElement(parent, 'logFileLink').text = str( - data.get('log-file-link', '')) - XML.SubElement(parent, 'reportFileName').text = str( - data.get('report-html', 'report.html')) - XML.SubElement(parent, 'logFileName').text = str( - data.get('log-html', 'log.html')) - XML.SubElement(parent, 'outputFileName').text = str( - data.get('output-xml', 'output.xml')) - XML.SubElement(parent, 'passThreshold').text = str( - data.get('pass-threshold', 0.0)) - XML.SubElement(parent, 'unstableThreshold').text = str( - data.get('unstable-threshold', 0.0)) - XML.SubElement(parent, 'onlyCritical').text = str( - data.get('only-critical', True)).lower() + parent.set('plugin', 'robot') + mappings = [ + ('output-path', 'outputPath', None), + ('log-file-link', 'logFileLink', ''), + ('report-html', 'reportFileName', 'report.html'), + ('log-html', 'logFileName', 'log.html'), + ('output-xml', 'outputFileName', 'output.xml'), + ('pass-threshold', 'passThreshold', '0.0'), + ('unstable-threshold', 'unstableThreshold', '0.0'), + ('only-critical', 'onlyCritical', True), + ('enable-cache', 'enableCache', True) + ] + helpers.convert_mapping_to_xml(parent, data, mappings, fail_required=True) + other_files = XML.SubElement(parent, 'otherFiles') - for other_file in data['other-files']: + for other_file in data.get('other-files', []): XML.SubElement(other_files, 'string').text = str(other_file) XML.SubElement(parent, 'disableArchiveOutput').text = str( not data.get('archive-output-xml', True)).lower() diff --git a/tests/publishers/fixtures/robot001.xml b/tests/publishers/fixtures/robot-complete.xml similarity index 87% rename from tests/publishers/fixtures/robot001.xml rename to tests/publishers/fixtures/robot-complete.xml index fdf227547..7c3ceaf17 100644 --- a/tests/publishers/fixtures/robot001.xml +++ b/tests/publishers/fixtures/robot-complete.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <project> <publishers> - <hudson.plugins.robot.RobotPublisher> + <hudson.plugins.robot.RobotPublisher plugin="robot"> <outputPath>reports/robot</outputPath> <logFileLink>report.html</logFileLink> <reportFileName>custom-report.html</reportFileName> @@ -10,6 +10,7 @@ <passThreshold>80.0</passThreshold> <unstableThreshold>60.0</unstableThreshold> <onlyCritical>false</onlyCritical> + <enableCache>false</enableCache> <otherFiles> <string>extra-file1.html</string> <string>extra-file2.txt</string> diff --git a/tests/publishers/fixtures/robot001.yaml b/tests/publishers/fixtures/robot-complete.yaml similarity index 93% rename from tests/publishers/fixtures/robot001.yaml rename to tests/publishers/fixtures/robot-complete.yaml index 30538b045..fa4019efe 100644 --- a/tests/publishers/fixtures/robot001.yaml +++ b/tests/publishers/fixtures/robot-complete.yaml @@ -8,6 +8,7 @@ publishers: pass-threshold: 80.0 unstable-threshold: 60.0 only-critical: false + enable-cache: false other-files: - extra-file1.html - extra-file2.txt diff --git a/tests/publishers/fixtures/robot-minimal.xml b/tests/publishers/fixtures/robot-minimal.xml new file mode 100644 index 000000000..05c484459 --- /dev/null +++ b/tests/publishers/fixtures/robot-minimal.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <hudson.plugins.robot.RobotPublisher plugin="robot"> + <outputPath>reports/robot</outputPath> + <logFileLink/> + <reportFileName>report.html</reportFileName> + <logFileName>log.html</logFileName> + <outputFileName>output.xml</outputFileName> + <passThreshold>0.0</passThreshold> + <unstableThreshold>0.0</unstableThreshold> + <onlyCritical>true</onlyCritical> + <enableCache>true</enableCache> + <otherFiles/> + <disableArchiveOutput>false</disableArchiveOutput> + </hudson.plugins.robot.RobotPublisher> + </publishers> +</project> diff --git a/tests/publishers/fixtures/robot-minimal.yaml b/tests/publishers/fixtures/robot-minimal.yaml new file mode 100644 index 000000000..8b26ce43d --- /dev/null +++ b/tests/publishers/fixtures/robot-minimal.yaml @@ -0,0 +1,3 @@ +publishers: + - robot: + output-path: reports/robot