From 3b79764615761ef1262fe8649ebb8f3f96b8e9c4 Mon Sep 17 00:00:00 2001 From: mlua Date: Thu, 23 Oct 2014 10:08:22 +0200 Subject: [PATCH] Added support for Rich Text Publisher Plugin This commit adds support for the Rich Text Publisher Plugin avaiable at https://wiki.jenkins-ci.org/display/JENKINS/Rich+Text+Publisher+Plugin Change-Id: Id3bf21dfe8ae5a6392fb15334461b0ce4a95e1ae --- jenkins_jobs/modules/publishers.py | 42 ++++++++++++++++++++++ setup.cfg | 1 + tests/publishers/fixtures/richtext001.xml | 13 +++++++ tests/publishers/fixtures/richtext001.yaml | 4 +++ tests/publishers/fixtures/richtext002.xml | 13 +++++++ tests/publishers/fixtures/richtext002.yaml | 5 +++ 6 files changed, 78 insertions(+) create mode 100644 tests/publishers/fixtures/richtext001.xml create mode 100644 tests/publishers/fixtures/richtext001.yaml create mode 100644 tests/publishers/fixtures/richtext002.xml create mode 100644 tests/publishers/fixtures/richtext002.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 3ef4b2b95..056e00f9d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -2230,6 +2230,48 @@ def html_publisher(parser, xml_parent, data): XML.SubElement(ptarget, 'wrapperName').text = "htmlpublisher-wrapper.html" +def rich_text_publisher(parser, xml_parent, data): + """yaml: rich_text_publisher + This plugin puts custom rich text message to the Build pages and Job main + page. + + Requires the Jenkins `Rich Text Publisher Plugin. + `_ + + :arg str stable-text: The stable text + :arg str unstable-text: The unstable text if different from stable + (default '') + :arg str failed-text: The failed text if different from stable (default '') + :arg str parser-name: HTML, Confluence or WikiText + + + Example: + + .. literalinclude:: /../../tests/publishers/fixtures/richtext001.yaml + :language: yaml + + """ + + parsers = ['HTML', 'Confluence', 'WikiText'] + parser_name = data['parser-name'] + if parser_name not in parsers: + raise JenkinsJobsException('parser-name must be one of: %s' % + ", ".join(parsers)) + + reporter = XML.SubElement( + xml_parent, + 'org.korosoft.jenkins.plugin.rtp.RichTextPublisher') + XML.SubElement(reporter, 'stableText').text = data['stable-text'] + XML.SubElement(reporter, 'unstableText').text =\ + data.get('unstable-text', '') + XML.SubElement(reporter, 'failedText').text = data.get('failed-text', '') + XML.SubElement(reporter, 'unstableAsStable').text =\ + 'False' if data.get('unstable-text', '') else 'True' + XML.SubElement(reporter, 'failedAsStable').text =\ + 'False' if data.get('failed-text', '') else 'True' + XML.SubElement(reporter, 'parserName').text = parser_name + + def tap(parser, xml_parent, data): """yaml: tap Adds support to TAP test result files diff --git a/setup.cfg b/setup.cfg index 287ffec8a..85c0193ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -149,6 +149,7 @@ jenkins_jobs.publishers = pmd=jenkins_jobs.modules.publishers:pmd post-tasks=jenkins_jobs.modules.publishers:post_tasks postbuildscript=jenkins_jobs.modules.publishers:postbuildscript + rich-text-publisher=jenkins_jobs.modules.publishers:rich_text_publisher robot=jenkins_jobs.modules.publishers:robot ruby-metrics=jenkins_jobs.modules.publishers:ruby_metrics scp=jenkins_jobs.modules.publishers:scp diff --git a/tests/publishers/fixtures/richtext001.xml b/tests/publishers/fixtures/richtext001.xml new file mode 100644 index 000000000..09879228c --- /dev/null +++ b/tests/publishers/fixtures/richtext001.xml @@ -0,0 +1,13 @@ + + + + + testing + + + True + True + HTML + + + diff --git a/tests/publishers/fixtures/richtext001.yaml b/tests/publishers/fixtures/richtext001.yaml new file mode 100644 index 000000000..09d94f068 --- /dev/null +++ b/tests/publishers/fixtures/richtext001.yaml @@ -0,0 +1,4 @@ +publishers: + - rich-text-publisher: + stable-text: testing + parser-name: HTML diff --git a/tests/publishers/fixtures/richtext002.xml b/tests/publishers/fixtures/richtext002.xml new file mode 100644 index 000000000..cd264274c --- /dev/null +++ b/tests/publishers/fixtures/richtext002.xml @@ -0,0 +1,13 @@ + + + + + the stable text + the unstable text + + False + True + HTML + + + diff --git a/tests/publishers/fixtures/richtext002.yaml b/tests/publishers/fixtures/richtext002.yaml new file mode 100644 index 000000000..052d0b6f2 --- /dev/null +++ b/tests/publishers/fixtures/richtext002.yaml @@ -0,0 +1,5 @@ +publishers: + - rich-text-publisher: + stable-text: the stable text + unstable-text: the unstable text + parser-name: HTML