From 2bb16b594dd529967d02f7c9607f15b85fb05cf2 Mon Sep 17 00:00:00 2001 From: Jesse DeFer Date: Fri, 13 Mar 2015 13:23:22 -0700 Subject: [PATCH] Add 'Job Log Logger' wrapper The Job Log Logger plugin writes the Jenkins job log to the underlying Jenkins log system in addition to the normal build log. Change-Id: I17b73ade974edf3d7a2d1e08c4e4c584dbe32c51 --- jenkins_jobs/modules/wrappers.py | 21 +++++++++++++++++++ setup.cfg | 1 + tests/wrappers/fixtures/job-log-logger001.xml | 8 +++++++ .../wrappers/fixtures/job-log-logger001.yaml | 3 +++ 4 files changed, 33 insertions(+) create mode 100644 tests/wrappers/fixtures/job-log-logger001.xml create mode 100644 tests/wrappers/fixtures/job-log-logger001.yaml diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 1546965e1..707315d35 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -1288,6 +1288,27 @@ def xvnc(parser, xml_parent, data): data.get('xauthority', True)).lower() +def job_log_logger(parser, xml_parent, data): + """yaml: job-log-logger + Enable writing the job log to the underlying logging system. + Requires the Jenkins :jenkins-wiki:`Job Log Logger plugin + `. + + :arg bool suppress-empty: Suppress empty log messages + (default: true) + + Example: + + .. literalinclude:: /../../tests/wrappers/fixtures/job-log-logger001.yaml + + """ + top = XML.SubElement(xml_parent, + 'org.jenkins.ci.plugins.jobloglogger.' + 'JobLogLoggerBuildWrapper') + XML.SubElement(top, 'suppressEmpty').text = str( + data.get('suppress-empty', True)).lower() + + class Wrappers(jenkins_jobs.modules.base.Base): sequence = 80 diff --git a/setup.cfg b/setup.cfg index bcbf09ffa..00c6d758f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -221,6 +221,7 @@ jenkins_jobs.wrappers = inject-passwords=jenkins_jobs.modules.wrappers:inject_passwords inject=jenkins_jobs.modules.wrappers:inject jclouds=jenkins_jobs.modules.wrappers:jclouds + job-log-logger=jenkins_jobs.modules.wrappers:job_log_logger locks=jenkins_jobs.modules.wrappers:locks logfilesize=jenkins_jobs.modules.wrappers:logfilesize logstash=jenkins_jobs.modules.wrappers:logstash diff --git a/tests/wrappers/fixtures/job-log-logger001.xml b/tests/wrappers/fixtures/job-log-logger001.xml new file mode 100644 index 000000000..702df6307 --- /dev/null +++ b/tests/wrappers/fixtures/job-log-logger001.xml @@ -0,0 +1,8 @@ + + + + + false + + + diff --git a/tests/wrappers/fixtures/job-log-logger001.yaml b/tests/wrappers/fixtures/job-log-logger001.yaml new file mode 100644 index 000000000..4c68d2a6c --- /dev/null +++ b/tests/wrappers/fixtures/job-log-logger001.yaml @@ -0,0 +1,3 @@ +wrappers: + - job-log-logger: + suppress-empty: false