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): `. :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 @@ - + reports/robot report.html custom-report.html @@ -10,6 +10,7 @@ 80.0 60.0 false + false extra-file1.html extra-file2.txt 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 @@ + + + + + reports/robot + + report.html + log.html + output.xml + 0.0 + 0.0 + true + true + + false + + + 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