summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAviel Yosef <ayosef@redhat.com>2019-07-17 09:24:29 +0300
committerAviel Yosef <ayosef@redhat.com>2019-07-19 09:14:06 +0300
commitc907f7708c2f6cdaaa91fab4506982026de84044 (patch)
tree46a43162048dcae90115e4c90fd67a1d3537f1dc
parentb0d0bad271bf598d9d22c5054c856f90df369e1b (diff)
downloadpython-jenkins-job-builder-c907f7708c2f6cdaaa91fab4506982026de84044.tar.gz
python-jenkins-job-builder-c907f7708c2f6cdaaa91fab4506982026de84044.tar.xz
python-jenkins-job-builder-c907f7708c2f6cdaaa91fab4506982026de84044.zip
Adding support for the cachet gating plugin
Change-Id: Ie50d25d09a094f2315e790288f3c3f1619ffdb7f
-rw-r--r--jenkins_jobs/modules/properties.py35
-rw-r--r--tests/properties/fixtures/cachet-gating.xml12
-rw-r--r--tests/properties/fixtures/cachet-gating.yaml6
3 files changed, 53 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py
index 8e06385e..22192e12 100644
--- a/jenkins_jobs/modules/properties.py
+++ b/jenkins_jobs/modules/properties.py
@@ -1217,6 +1217,41 @@ def disable_resume(registry, xml_parent, data):
'DisableResumeJobProperty')
+def cachet_gating(registry, xml_parent, data):
+ """yaml: cachet-gating
+ The Cachet Gating Plugin provides a gating mechanism
+ based on the availability of resources.
+
+ Requires the Jenkins: :jenkins-wiki:`Cachet Gate Plugin
+ <Cachet+Gate+Plugin>`.
+
+ :arg bool required-resources: Confirm availability of listed
+ resources before building. Requires the list of resources to
+ also be defined. (default true)
+ :arg list resources: which resources to gate
+
+ Example:
+
+ .. literalinclude:: /../../tests/properties/fixtures/cachet-gating.yaml
+ :language: yaml
+ """
+ cachet = XML.SubElement(
+ xml_parent, 'com.redhat.jenkins.plugins.cachet.CachetJobProperty')
+ cachet.set('plugin', 'cachet-gating')
+
+ mapping = [
+ ('required-resources', 'requiredResources', True),
+ ]
+ helpers.convert_mapping_to_xml(
+ cachet, data, mapping, fail_required=True)
+
+ resources_data = data.get('resources', [])
+ if resources_data:
+ resources = XML.SubElement(cachet, 'resources')
+ for resource in resources_data:
+ XML.SubElement(resources, 'string').text = str(resource)
+
+
class Properties(jenkins_jobs.modules.base.Base):
sequence = 20
diff --git a/tests/properties/fixtures/cachet-gating.xml b/tests/properties/fixtures/cachet-gating.xml
new file mode 100644
index 00000000..d71a3443
--- /dev/null
+++ b/tests/properties/fixtures/cachet-gating.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <properties>
+ <com.redhat.jenkins.plugins.cachet.CachetJobProperty plugin="cachet-gating">
+ <requiredResources>true</requiredResources>
+ <resources>
+ <string>beaker</string>
+ <string>brew</string>
+ </resources>
+ </com.redhat.jenkins.plugins.cachet.CachetJobProperty>
+ </properties>
+</project>
diff --git a/tests/properties/fixtures/cachet-gating.yaml b/tests/properties/fixtures/cachet-gating.yaml
new file mode 100644
index 00000000..8c514cd9
--- /dev/null
+++ b/tests/properties/fixtures/cachet-gating.yaml
@@ -0,0 +1,6 @@
+properties:
+ - cachet-gating:
+ required-resources: true
+ resources:
+ - beaker
+ - brew