diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index c53eb2652..96864454d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3261,6 +3261,37 @@ def sitemonitor(parser, xml_parent, data): XML.SubElement(site, 'mUrl').text = siteurl['url'] +def testng(parser, xml_parent, data): + """yaml: testng + This plugin publishes TestNG test reports. + + Requires the Jenkins `TestNG Results Plugin. + `_ + + :arg str pattern: filename pattern to locate the TestNG XML report files + :arg bool escape-test-description: escapes the description string + associated with the test method while displaying test method details + (Default True) + :arg bool escape-exception-msg: escapes the test method's exception + messages. (Default True) + + Example:: + + .. literalinclude:: + /../../tests/publishers/fixtures/testng001.yaml + + """ + + reporter = XML.SubElement(xml_parent, 'hudson.plugins.testng.Publisher') + if not data['pattern']: + raise JenkinsJobsException("A filename pattern must be specified.") + XML.SubElement(reporter, 'reportFilenamePattern').text = data['pattern'] + XML.SubElement(reporter, 'escapeTestDescp').text = str(data.get( + 'escape-test-description', True)) + XML.SubElement(reporter, 'escapeExceptionMsg').text = str(data.get( + 'escape-exception-msg', True)) + + class Publishers(jenkins_jobs.modules.base.Base): sequence = 70 diff --git a/setup.py b/setup.py index 1a2b625c8..722c67053 100644 --- a/setup.py +++ b/setup.py @@ -169,6 +169,7 @@ setuptools.setup( 'ssh=jenkins_jobs.modules.publishers:ssh', 'stash=jenkins_jobs.modules.publishers:stash', 'tap=jenkins_jobs.modules.publishers:tap', + 'testng=jenkins_jobs.modules.publishers:testng', 'text-finder=jenkins_jobs.modules.publishers:text_finder', 'trigger=jenkins_jobs.modules.publishers:trigger', ('trigger-parameterized-builds=' diff --git a/tests/publishers/fixtures/testng001.xml b/tests/publishers/fixtures/testng001.xml new file mode 100644 index 000000000..e33608c42 --- /dev/null +++ b/tests/publishers/fixtures/testng001.xml @@ -0,0 +1,10 @@ + + + + + **/target/surefire-reports/testng-results.xml + False + True + + + diff --git a/tests/publishers/fixtures/testng001.yaml b/tests/publishers/fixtures/testng001.yaml new file mode 100644 index 000000000..9071c2751 --- /dev/null +++ b/tests/publishers/fixtures/testng001.yaml @@ -0,0 +1,5 @@ +publishers: + - testng: + pattern: "**/target/surefire-reports/testng-results.xml" + escape-test-description: false + escape-exception-msg: true