diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 8579b10b9..08fc65c04 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -324,6 +324,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 4df40081f..1ad0b2b5a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -247,6 +247,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