Adds match-script and groovy-sandbox to Lockable Resources Plugin properties
Change-Id: I45db7b1a58f2dea4d46aba61aaf16383d30f1b50
This commit is contained in:
parent
c59b5a5258
commit
0f2c43fccf
|
@ -1103,6 +1103,10 @@ def lockable_resources(registry, xml_parent, data):
|
||||||
:arg int number: Number of resources to request, empty value or 0 means
|
:arg int number: Number of resources to request, empty value or 0 means
|
||||||
all. This is useful, if you have a pool of similar resources,
|
all. This is useful, if you have a pool of similar resources,
|
||||||
from which you want one or more to be reserved. (default 0)
|
from which you want one or more to be reserved. (default 0)
|
||||||
|
:arg str match-script: Groovy script to reserve resource based on its
|
||||||
|
properties. Leave empty to disable. (default None)
|
||||||
|
:arg bool groovy-sandbox: Execute the provided match-script in Groovy
|
||||||
|
sandbox. Leave empty to disable. (default False)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -1117,6 +1121,10 @@ def lockable_resources(registry, xml_parent, data):
|
||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
/../../tests/properties/fixtures/lockable_resources_full.yaml
|
/../../tests/properties/fixtures/lockable_resources_full.yaml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
/../../tests/properties/fixtures/lockable_resources_groovy.yaml
|
||||||
|
:language: yaml
|
||||||
"""
|
"""
|
||||||
lockable_resources = XML.SubElement(
|
lockable_resources = XML.SubElement(
|
||||||
xml_parent,
|
xml_parent,
|
||||||
|
@ -1131,6 +1139,14 @@ def lockable_resources(registry, xml_parent, data):
|
||||||
]
|
]
|
||||||
helpers.convert_mapping_to_xml(
|
helpers.convert_mapping_to_xml(
|
||||||
lockable_resources, data, mapping, fail_required=True)
|
lockable_resources, data, mapping, fail_required=True)
|
||||||
|
secure_groovy_script = XML.SubElement(lockable_resources,
|
||||||
|
'resourceMatchScript')
|
||||||
|
mapping = [
|
||||||
|
('match-script', 'script', None),
|
||||||
|
('groovy-sandbox', 'sandbox', False),
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(secure_groovy_script, data, mapping,
|
||||||
|
fail_required=False)
|
||||||
|
|
||||||
|
|
||||||
def docker_container(registry, xml_parent, data):
|
def docker_container(registry, xml_parent, data):
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
<resourceNamesVar>RESOURCE_NAME</resourceNamesVar>
|
<resourceNamesVar>RESOURCE_NAME</resourceNamesVar>
|
||||||
<resourceNumber>10</resourceNumber>
|
<resourceNumber>10</resourceNumber>
|
||||||
<labelName/>
|
<labelName/>
|
||||||
|
<resourceMatchScript>
|
||||||
|
<sandbox>false</sandbox>
|
||||||
|
</resourceMatchScript>
|
||||||
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<properties>
|
||||||
|
<org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
||||||
|
<resourceNames/>
|
||||||
|
<resourceNamesVar/>
|
||||||
|
<resourceNumber>0</resourceNumber>
|
||||||
|
<labelName/>
|
||||||
|
<resourceMatchScript>
|
||||||
|
<script>resourceName == MY_VAR</script>
|
||||||
|
<sandbox>true</sandbox>
|
||||||
|
</resourceMatchScript>
|
||||||
|
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
properties:
|
||||||
|
- lockable-resources:
|
||||||
|
match-script: "resourceName == MY_VAR"
|
||||||
|
groovy-sandbox: true
|
|
@ -6,6 +6,9 @@
|
||||||
<resourceNamesVar/>
|
<resourceNamesVar/>
|
||||||
<resourceNumber>0</resourceNumber>
|
<resourceNumber>0</resourceNumber>
|
||||||
<labelName>pool-1</labelName>
|
<labelName>pool-1</labelName>
|
||||||
|
<resourceMatchScript>
|
||||||
|
<sandbox>false</sandbox>
|
||||||
|
</resourceMatchScript>
|
||||||
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
<resourceNamesVar/>
|
<resourceNamesVar/>
|
||||||
<resourceNumber>0</resourceNumber>
|
<resourceNumber>0</resourceNumber>
|
||||||
<labelName/>
|
<labelName/>
|
||||||
|
<resourceMatchScript>
|
||||||
|
<sandbox>false</sandbox>
|
||||||
|
</resourceMatchScript>
|
||||||
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
</org.jenkins.plugins.lockableresources.RequiredResourcesProperty>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue