Adding support for the cachet gating plugin
Change-Id: Ie50d25d09a094f2315e790288f3c3f1619ffdb7f
This commit is contained in:
parent
b0d0bad271
commit
c907f7708c
@ -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
|
||||
|
||||
|
12
tests/properties/fixtures/cachet-gating.xml
Normal file
12
tests/properties/fixtures/cachet-gating.xml
Normal file
@ -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>
|
6
tests/properties/fixtures/cachet-gating.yaml
Normal file
6
tests/properties/fixtures/cachet-gating.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
properties:
|
||||
- cachet-gating:
|
||||
required-resources: true
|
||||
resources:
|
||||
- beaker
|
||||
- brew
|
Loading…
Reference in New Issue
Block a user