Support for image gallery publisher
Produce an image gallery using Javascript library using the https://wiki.jenkins-ci.org/display/JENKINS/Image+Gallery+Plugin Change-Id: I462c331dd989e43e100c9f23afec0529824514fa
This commit is contained in:
parent
75aabd6e81
commit
12db2deb6e
@ -31,7 +31,7 @@ import jenkins_jobs.modules.base
|
|||||||
from jenkins_jobs.modules import hudson_model
|
from jenkins_jobs.modules import hudson_model
|
||||||
from jenkins_jobs.modules.helpers import build_trends_publisher
|
from jenkins_jobs.modules.helpers import build_trends_publisher
|
||||||
from jenkins_jobs.modules.helpers import findbugs_settings
|
from jenkins_jobs.modules.helpers import findbugs_settings
|
||||||
from jenkins_jobs.errors import JenkinsJobsException
|
from jenkins_jobs.errors import JenkinsJobsException, InvalidAttributeError
|
||||||
import logging
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import sys
|
import sys
|
||||||
@ -4329,6 +4329,80 @@ def logstash(parser, xml_parent, data):
|
|||||||
data.get('fail-build', False))
|
data.get('fail-build', False))
|
||||||
|
|
||||||
|
|
||||||
|
def image_gallery(parser, xml_parent, data):
|
||||||
|
"""yaml: image-gallery
|
||||||
|
Produce an image gallery using Javascript library. Requires the Jenkins
|
||||||
|
:jenkins-wiki:`Image Gallery Plugin<Image+Gallery+Plugin>`.
|
||||||
|
|
||||||
|
:arg str gallery-type:
|
||||||
|
|
||||||
|
:gallery-type values:
|
||||||
|
* **archived-images-gallery** (default)
|
||||||
|
* **in-folder-comparative-gallery**
|
||||||
|
* **multiple-folder-comparative-gallery**
|
||||||
|
:arg str title: gallery title (optional)
|
||||||
|
:arg int image-width: width of the image (optional)
|
||||||
|
:arg bool unstable-if-no-artifacts: mark build as unstable
|
||||||
|
if no archived artifacts were found (default False)
|
||||||
|
:arg str includes: include pattern (valid for archived-images-gallery
|
||||||
|
gallery)
|
||||||
|
:arg str base-root-folder: base root dir (valid for comparative gallery)
|
||||||
|
:arg int image-inner-width: width of the image displayed in the inner
|
||||||
|
gallery popup (valid for comparative gallery, optional)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/image-gallery001.yaml
|
||||||
|
|
||||||
|
"""
|
||||||
|
def include_comparative_elements(gallery_parent_elem, gallery):
|
||||||
|
XML.SubElement(gallery_parent_elem, 'baseRootFolder').text = str(
|
||||||
|
gallery.get('base-root-folder', ''))
|
||||||
|
image_inner_width = gallery.get('image-inner-width', '')
|
||||||
|
if image_inner_width:
|
||||||
|
XML.SubElement(gallery_parent_elem, 'imageInnerWidth').text = str(
|
||||||
|
image_inner_width)
|
||||||
|
|
||||||
|
package_prefix = 'org.jenkinsci.plugins.imagegallery.'
|
||||||
|
builder = XML.SubElement(
|
||||||
|
xml_parent, package_prefix + 'ImageGalleryRecorder'
|
||||||
|
)
|
||||||
|
image_galleries = XML.SubElement(builder, 'imageGalleries')
|
||||||
|
galleries = {
|
||||||
|
'archived-images-gallery': package_prefix + 'imagegallery.'
|
||||||
|
'ArchivedImagesGallery',
|
||||||
|
'in-folder-comparative-gallery': package_prefix + 'comparative.'
|
||||||
|
'InFolderComparativeArchivedImagesGallery',
|
||||||
|
'multiple-folder-comparative-gallery': package_prefix + 'comparative.'
|
||||||
|
'MultipleFolderComparativeArchivedImagesGallery'
|
||||||
|
}
|
||||||
|
for gallery_def in data:
|
||||||
|
gallery_type = gallery_def.get('gallery-type',
|
||||||
|
'archived-images-gallery')
|
||||||
|
if gallery_type not in galleries:
|
||||||
|
raise InvalidAttributeError('gallery-type', gallery_type,
|
||||||
|
galleries.keys())
|
||||||
|
gallery_config = XML.SubElement(
|
||||||
|
image_galleries, galleries[gallery_type])
|
||||||
|
XML.SubElement(gallery_config, 'title').text = str(
|
||||||
|
gallery_def.get('title', ''))
|
||||||
|
image_width = str(gallery_def.get('image-width', ''))
|
||||||
|
if image_width:
|
||||||
|
XML.SubElement(gallery_config, 'imageWidth').text = str(
|
||||||
|
image_width)
|
||||||
|
XML.SubElement(
|
||||||
|
gallery_config,
|
||||||
|
'markBuildAsUnstableIfNoArchivesFound').text = str(gallery_def.get(
|
||||||
|
'unstable-if-no-artifacts', False))
|
||||||
|
if gallery_type == 'archived-images-gallery':
|
||||||
|
XML.SubElement(gallery_config, 'includes').text = str(
|
||||||
|
gallery_def.get('includes', ''))
|
||||||
|
if gallery_type == 'in-folder-comparative-gallery':
|
||||||
|
include_comparative_elements(gallery_config, gallery_def)
|
||||||
|
if gallery_type == 'multiple-folder-comparative-gallery':
|
||||||
|
include_comparative_elements(gallery_config, gallery_def)
|
||||||
|
|
||||||
|
|
||||||
class Publishers(jenkins_jobs.modules.base.Base):
|
class Publishers(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 70
|
sequence = 70
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ jenkins_jobs.publishers =
|
|||||||
github-notifier=jenkins_jobs.modules.publishers:github_notifier
|
github-notifier=jenkins_jobs.modules.publishers:github_notifier
|
||||||
groovy-postbuild=jenkins_jobs.modules.publishers:groovy_postbuild
|
groovy-postbuild=jenkins_jobs.modules.publishers:groovy_postbuild
|
||||||
html-publisher=jenkins_jobs.modules.publishers:html_publisher
|
html-publisher=jenkins_jobs.modules.publishers:html_publisher
|
||||||
|
image-gallery=jenkins_jobs.modules.publishers:image_gallery
|
||||||
ircbot=jenkins_jobs.modules.publishers:ircbot
|
ircbot=jenkins_jobs.modules.publishers:ircbot
|
||||||
jabber=jenkins_jobs.modules.publishers:jabber
|
jabber=jenkins_jobs.modules.publishers:jabber
|
||||||
jacoco=jenkins_jobs.modules.publishers:jacoco
|
jacoco=jenkins_jobs.modules.publishers:jacoco
|
||||||
|
29
tests/publishers/fixtures/image-gallery001.xml
Normal file
29
tests/publishers/fixtures/image-gallery001.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.ImageGalleryRecorder>
|
||||||
|
<imageGalleries>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<title>Gallery 1</title>
|
||||||
|
<imageWidth>100</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>True</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<includes>path/images</includes>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.comparative.InFolderComparativeArchivedImagesGallery>
|
||||||
|
<title>Gallery 2</title>
|
||||||
|
<imageWidth>321</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>False</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<baseRootFolder>path/images2</baseRootFolder>
|
||||||
|
<imageInnerWidth>111</imageInnerWidth>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.comparative.InFolderComparativeArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.comparative.MultipleFolderComparativeArchivedImagesGallery>
|
||||||
|
<title>Gallery 3</title>
|
||||||
|
<imageWidth>222</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>False</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<baseRootFolder>path/images3</baseRootFolder>
|
||||||
|
<imageInnerWidth>1</imageInnerWidth>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.comparative.MultipleFolderComparativeArchivedImagesGallery>
|
||||||
|
</imageGalleries>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.ImageGalleryRecorder>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
18
tests/publishers/fixtures/image-gallery001.yaml
Normal file
18
tests/publishers/fixtures/image-gallery001.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
publishers:
|
||||||
|
- image-gallery:
|
||||||
|
- gallery-type: archived-images-gallery
|
||||||
|
title: Gallery 1
|
||||||
|
includes: path/images
|
||||||
|
image-width: 100
|
||||||
|
unstable-if-no-artifacts: true
|
||||||
|
- gallery-type: in-folder-comparative-gallery
|
||||||
|
title: Gallery 2
|
||||||
|
base-root-folder: path/images2
|
||||||
|
image-width: 321
|
||||||
|
image-inner-width: 111
|
||||||
|
unstable-if-no-artifacts: false
|
||||||
|
- gallery-type: multiple-folder-comparative-gallery
|
||||||
|
title: Gallery 3
|
||||||
|
base-root-folder: path/images3
|
||||||
|
image-width: 222
|
||||||
|
image-inner-width: 1
|
44
tests/publishers/fixtures/image-gallery002.xml
Normal file
44
tests/publishers/fixtures/image-gallery002.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.ImageGalleryRecorder>
|
||||||
|
<imageGalleries>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<title>Gallery 1</title>
|
||||||
|
<imageWidth>100</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>True</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<includes>path/images</includes>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<title/>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>False</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<includes/>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.comparative.InFolderComparativeArchivedImagesGallery>
|
||||||
|
<title>Gallery 3</title>
|
||||||
|
<imageWidth>321</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>True</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<baseRootFolder>path/images3</baseRootFolder>
|
||||||
|
<imageInnerWidth>111</imageInnerWidth>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.comparative.InFolderComparativeArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.comparative.InFolderComparativeArchivedImagesGallery>
|
||||||
|
<title/>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>False</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<baseRootFolder/>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.comparative.InFolderComparativeArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.comparative.MultipleFolderComparativeArchivedImagesGallery>
|
||||||
|
<title>Gallery 5</title>
|
||||||
|
<imageWidth>444</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>True</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<baseRootFolder>path/images5</baseRootFolder>
|
||||||
|
<imageInnerWidth>333</imageInnerWidth>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.comparative.MultipleFolderComparativeArchivedImagesGallery>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.comparative.MultipleFolderComparativeArchivedImagesGallery>
|
||||||
|
<title/>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>False</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<baseRootFolder/>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.comparative.MultipleFolderComparativeArchivedImagesGallery>
|
||||||
|
</imageGalleries>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.ImageGalleryRecorder>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
22
tests/publishers/fixtures/image-gallery002.yaml
Normal file
22
tests/publishers/fixtures/image-gallery002.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
publishers:
|
||||||
|
- image-gallery:
|
||||||
|
- gallery-type: archived-images-gallery
|
||||||
|
title: Gallery 1
|
||||||
|
includes: path/images
|
||||||
|
image-width: 100
|
||||||
|
unstable-if-no-artifacts: true
|
||||||
|
- gallery-type: archived-images-gallery
|
||||||
|
- gallery-type: in-folder-comparative-gallery
|
||||||
|
title: Gallery 3
|
||||||
|
base-root-folder: path/images3
|
||||||
|
image-width: 321
|
||||||
|
image-inner-width: 111
|
||||||
|
unstable-if-no-artifacts: true
|
||||||
|
- gallery-type: in-folder-comparative-gallery
|
||||||
|
- gallery-type: multiple-folder-comparative-gallery
|
||||||
|
title: Gallery 5
|
||||||
|
base-root-folder: path/images5
|
||||||
|
image-width: 444
|
||||||
|
image-inner-width: 333
|
||||||
|
unstable-if-no-artifacts: true
|
||||||
|
- gallery-type: multiple-folder-comparative-gallery
|
15
tests/publishers/fixtures/image-gallery003.xml
Normal file
15
tests/publishers/fixtures/image-gallery003.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.ImageGalleryRecorder>
|
||||||
|
<imageGalleries>
|
||||||
|
<org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
<title>Gallery 1</title>
|
||||||
|
<imageWidth>100</imageWidth>
|
||||||
|
<markBuildAsUnstableIfNoArchivesFound>False</markBuildAsUnstableIfNoArchivesFound>
|
||||||
|
<includes>path/images</includes>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.imagegallery.ArchivedImagesGallery>
|
||||||
|
</imageGalleries>
|
||||||
|
</org.jenkinsci.plugins.imagegallery.ImageGalleryRecorder>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
6
tests/publishers/fixtures/image-gallery003.yaml
Normal file
6
tests/publishers/fixtures/image-gallery003.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
publishers:
|
||||||
|
- image-gallery:
|
||||||
|
- title: Gallery 1
|
||||||
|
includes: path/images
|
||||||
|
image-width: 100
|
||||||
|
unstable-if-no-artifacts: false
|
Loading…
x
Reference in New Issue
Block a user