From bc73928d0ff519b2d2e231cf8ef72de3491f26a8 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Mon, 29 Jun 2015 20:14:40 +0100 Subject: [PATCH] Adding support for LiveScreenshot Plugin https://wiki.jenkins-ci.org/display/JENKINS/LiveScreenshot+Plugin You can find the original version of this patch here: https://github.com/h01ger/jenkins-job-builder/commit/a1be29b0a3df05641fa45c3cddbdb4f0a6eb8903 My (Philip Hands's) contribution is limited to moving the one line from setup.py to setup.cfg, fixing a couple of very minor pep8 errors, adding the unit test, and submitting it upstream (now). I've therefore set the Author to be Holger. It is being submitted upstream by me (Philip Hands) with Holger's approval, because he doesn't have the time available to do it himself. Change-Id: I57a19786f202ebdb2f98cd63252b1a1e1639d9b3 Co-Authored-By: Philip Hands --- jenkins_jobs/modules/wrappers.py | 28 +++++++++++++++++++ setup.cfg | 1 + .../wrappers/fixtures/live_screenshot001.xml | 9 ++++++ .../wrappers/fixtures/live_screenshot001.yaml | 2 ++ .../wrappers/fixtures/live_screenshot002.xml | 9 ++++++ .../wrappers/fixtures/live_screenshot002.yaml | 4 +++ 6 files changed, 53 insertions(+) create mode 100644 tests/wrappers/fixtures/live_screenshot001.xml create mode 100644 tests/wrappers/fixtures/live_screenshot001.yaml create mode 100644 tests/wrappers/fixtures/live_screenshot002.xml create mode 100644 tests/wrappers/fixtures/live_screenshot002.yaml diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index e0a6bb371..acbe9d1df 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -216,6 +216,34 @@ def ansicolor(parser, xml_parent, data): XML.SubElement(cwrapper, 'colorMapName').text = colormap +def live_screenshot(parser, xml_parent, data): + """yaml: live-screenshot + Show live screenshots of running jobs in the job list. + Requires the Jenkins :jenkins-wiki:`Live-Screenshot Plugin + `. + + :arg str full-size: name of screenshot file (default 'screenshot.png') + :arg str thumbnail: name of thumbnail file (default 'screenshot-thumb.png') + + File type must be .png and they must be located inside the $WORKDIR. + + Example using defaults: + + .. literalinclude:: /../../tests/wrappers/fixtures/live_screenshot001.yaml + + or specifying the files to use: + + .. literalinclude:: /../../tests/wrappers/fixtures/live_screenshot002.yaml + """ + live = XML.SubElement( + xml_parent, + 'org.jenkinsci.plugins.livescreenshot.LiveScreenshotBuildWrapper') + XML.SubElement(live, 'fullscreenFilename').text = data.get( + 'full-size', 'screenshot.png') + XML.SubElement(live, 'thumbnailFilename').text = data.get( + 'thumbnail', 'screenshot-thumb.png') + + def mask_passwords(parser, xml_parent, data): """yaml: mask-passwords Hide passwords in the console log. diff --git a/setup.cfg b/setup.cfg index 27905757f..9a4edc478 100644 --- a/setup.cfg +++ b/setup.cfg @@ -244,6 +244,7 @@ jenkins_jobs.wrappers = inject=jenkins_jobs.modules.wrappers:inject jclouds=jenkins_jobs.modules.wrappers:jclouds job-log-logger=jenkins_jobs.modules.wrappers:job_log_logger + live-screenshot=jenkins_jobs.modules.wrappers:live_screenshot locks=jenkins_jobs.modules.wrappers:locks logfilesize=jenkins_jobs.modules.wrappers:logfilesize logstash=jenkins_jobs.modules.wrappers:logstash diff --git a/tests/wrappers/fixtures/live_screenshot001.xml b/tests/wrappers/fixtures/live_screenshot001.xml new file mode 100644 index 000000000..a315e599c --- /dev/null +++ b/tests/wrappers/fixtures/live_screenshot001.xml @@ -0,0 +1,9 @@ + + + + + screenshot.png + screenshot-thumb.png + + + diff --git a/tests/wrappers/fixtures/live_screenshot001.yaml b/tests/wrappers/fixtures/live_screenshot001.yaml new file mode 100644 index 000000000..aab365674 --- /dev/null +++ b/tests/wrappers/fixtures/live_screenshot001.yaml @@ -0,0 +1,2 @@ +wrappers: + - live-screenshot diff --git a/tests/wrappers/fixtures/live_screenshot002.xml b/tests/wrappers/fixtures/live_screenshot002.xml new file mode 100644 index 000000000..00b6bf45f --- /dev/null +++ b/tests/wrappers/fixtures/live_screenshot002.xml @@ -0,0 +1,9 @@ + + + + + my_screenshot.png + my_screenshot-thumb.png + + + diff --git a/tests/wrappers/fixtures/live_screenshot002.yaml b/tests/wrappers/fixtures/live_screenshot002.yaml new file mode 100644 index 000000000..9bf1087de --- /dev/null +++ b/tests/wrappers/fixtures/live_screenshot002.yaml @@ -0,0 +1,4 @@ +wrappers: + - live-screenshot: + full-size: my_screenshot.png + thumbnail: my_screenshot-thumb.png