Add support for Jenkins Gating property

https: //github.com/jenkinsci/gating-core-plugin
Change-Id: Ia649fe13e3add2c8d6125b775e376621d9d0408d
This commit is contained in:
Oliver Gondza 2021-02-01 10:56:22 +01:00
parent 575b0520f1
commit 572cb7abdd
3 changed files with 54 additions and 0 deletions

View File

@ -1259,6 +1259,41 @@ def disable_resume(registry, xml_parent, data):
)
def resource_gating(registry, xml_parent, data):
"""yaml: resource-gating
Jenkins Gating enables requiring external resources to be available before
build starts.
Requires the Jenkins: :jenkins-plugins:`Jenkins Gating <gating-core>`.
:arg list resources: Resource identifiers to be up before building
Example:
.. literalinclude:: /../../tests/properties/fixtures/gating-core.yaml
:language: yaml
"""
if "resources" not in data.keys():
raise MissingAttributeError("resources")
gating = XML.SubElement(
xml_parent, "io.jenkins.plugins.gating.ResourceRequirementProperty"
)
gating.set("plugin", "gating-core")
resources = XML.SubElement(gating, "resources")
resources.set("class", "java.util.Collections$UnmodifiableRandomAccessList")
resources.set("resolves-to", "java.util.Collections$UnmodifiableList")
c = XML.SubElement(resources, "c")
c.set("class", "list")
for resource in data["resources"]:
XML.SubElement(c, "string").text = str(resource)
lst = XML.SubElement(resources, "list")
lst.set("reference", "../c")
def cachet_gating(registry, xml_parent, data):
"""yaml: cachet-gating
The Cachet Gating Plugin provides a gating mechanism

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<io.jenkins.plugins.gating.ResourceRequirementProperty plugin="gating-core">
<resources class="java.util.Collections$UnmodifiableRandomAccessList" resolves-to="java.util.Collections$UnmodifiableList">
<c class="list">
<string>external/ci.example.com</string>
<string>foo/bar/baz</string>
</c>
<list reference="../c"/>
</resources>
</io.jenkins.plugins.gating.ResourceRequirementProperty>
</properties>
</project>

View File

@ -0,0 +1,5 @@
properties:
- resource-gating:
resources:
- external/ci.example.com
- foo/bar/baz