Improve support for nodelabelparameter
Adds support for all fields for nodelabelparameter. Uploaded new tests, including one that covers existing behavior to prevent regression. Story: #2001287 Task: #5835 Change-Id: I9dc4574427626fd56ba41149f0f6ab131a22e966
This commit is contained in:
parent
307c09cff3
commit
3308fd53bb
@ -191,19 +191,49 @@ def label_param(registry, xml_parent, data):
|
||||
:arg str name: the name of the parameter
|
||||
:arg str default: the default value of the parameter (optional)
|
||||
:arg str description: a description of the parameter (optional)
|
||||
:arg str matching-label: to run all nodes matching label
|
||||
'success', 'unstable' or 'allCases' (optional)
|
||||
:arg str node-eligibility: all nodes, ignore temporary nodes or
|
||||
ignore temporary offline nodes (optional, default all nodes)
|
||||
|
||||
Example::
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/parameters/fixtures/node-label001.yaml
|
||||
:language: yaml
|
||||
|
||||
parameters:
|
||||
- label:
|
||||
name: node
|
||||
default: precise
|
||||
description: "The node on which to run the job"
|
||||
"""
|
||||
base_param(registry, xml_parent, data, True,
|
||||
|
||||
pdef = base_param(registry, xml_parent, data, True,
|
||||
'org.jvnet.jenkins.plugins.nodelabelparameter.'
|
||||
'LabelParameterDefinition')
|
||||
|
||||
XML.SubElement(pdef, 'allNodesMatchingLabel').text = "true"
|
||||
|
||||
valid_types = ['allCases', 'success', 'unstable']
|
||||
mapping = [
|
||||
('matching-label', 'triggerIfResult', 'allCases', valid_types)
|
||||
]
|
||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||
|
||||
eligibility_label = data.get('node-eligibility', 'all').lower()
|
||||
eligibility_label_dict = {
|
||||
'all': 'org.jvnet.jenkins.plugins.'
|
||||
'nodelabelparameter.node.'
|
||||
'AllNodeEligibility',
|
||||
'ignore-offline': 'org.jvnet.jenkins.plugins.'
|
||||
'nodelabelparameter.node.'
|
||||
'IgnoreOfflineNodeEligibility',
|
||||
'ignore-temp-offline': 'org.jvnet.jenkins.plugins.'
|
||||
'nodelabelparameter.node.'
|
||||
'IgnoreTempOfflineNodeEligibility',
|
||||
}
|
||||
if eligibility_label not in eligibility_label_dict:
|
||||
raise InvalidAttributeError(eligibility_label, eligibility_label,
|
||||
eligibility_label_dict.keys())
|
||||
|
||||
XML.SubElement(pdef, 'nodeEligibility').set(
|
||||
"class", eligibility_label_dict[eligibility_label])
|
||||
|
||||
|
||||
def node_param(registry, xml_parent, data):
|
||||
"""yaml: node
|
||||
|
17
tests/parameters/fixtures/node-label001.xml
Normal file
17
tests/parameters/fixtures/node-label001.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
<name>EXAMPLE LABEL 1</name>
|
||||
<description>EXAMPLE LABEL DESCRIPTION 1</description>
|
||||
<defaultValue/>
|
||||
<allNodesMatchingLabel>true</allNodesMatchingLabel>
|
||||
<triggerIfResult>success</triggerIfResult>
|
||||
<nodeEligibility class="org.jvnet.jenkins.plugins.nodelabelparameter.node.AllNodeEligibility"/>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
6
tests/parameters/fixtures/node-label001.yaml
Normal file
6
tests/parameters/fixtures/node-label001.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
parameters:
|
||||
- label:
|
||||
name: EXAMPLE LABEL 1
|
||||
description: "EXAMPLE LABEL DESCRIPTION 1"
|
||||
matching-label: "success"
|
||||
node-eligibility: "all"
|
17
tests/parameters/fixtures/node-label002.xml
Normal file
17
tests/parameters/fixtures/node-label002.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
<name>EXAMPLE LABEL 2</name>
|
||||
<description>EXAMPLE LABEL DESCRIPTION 2</description>
|
||||
<defaultValue/>
|
||||
<allNodesMatchingLabel>true</allNodesMatchingLabel>
|
||||
<triggerIfResult>unstable</triggerIfResult>
|
||||
<nodeEligibility class="org.jvnet.jenkins.plugins.nodelabelparameter.node.IgnoreOfflineNodeEligibility"/>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
6
tests/parameters/fixtures/node-label002.yaml
Normal file
6
tests/parameters/fixtures/node-label002.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
parameters:
|
||||
- label:
|
||||
name: EXAMPLE LABEL 2
|
||||
description: "EXAMPLE LABEL DESCRIPTION 2"
|
||||
matching-label: "unstable"
|
||||
node-eligibility: "ignore-offline"
|
17
tests/parameters/fixtures/node-label003.xml
Normal file
17
tests/parameters/fixtures/node-label003.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
<name>EXAMPLE LABEL 3</name>
|
||||
<description>EXAMPLE LABEL DESCRIPTION 3</description>
|
||||
<defaultValue/>
|
||||
<allNodesMatchingLabel>true</allNodesMatchingLabel>
|
||||
<triggerIfResult>allCases</triggerIfResult>
|
||||
<nodeEligibility class="org.jvnet.jenkins.plugins.nodelabelparameter.node.IgnoreTempOfflineNodeEligibility"/>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
6
tests/parameters/fixtures/node-label003.yaml
Normal file
6
tests/parameters/fixtures/node-label003.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
parameters:
|
||||
- label:
|
||||
name: EXAMPLE LABEL 3
|
||||
description: "EXAMPLE LABEL DESCRIPTION 3"
|
||||
matching-label: "allCases"
|
||||
node-eligibility: "ignore-temp-offline"
|
17
tests/parameters/fixtures/node-label004.xml
Normal file
17
tests/parameters/fixtures/node-label004.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
<name>EXAMPLE LABEL 4</name>
|
||||
<description>EXAMPLE LABEL DESCRIPTION 4</description>
|
||||
<defaultValue/>
|
||||
<allNodesMatchingLabel>true</allNodesMatchingLabel>
|
||||
<triggerIfResult>allCases</triggerIfResult>
|
||||
<nodeEligibility class="org.jvnet.jenkins.plugins.nodelabelparameter.node.AllNodeEligibility"/>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
4
tests/parameters/fixtures/node-label004.yaml
Normal file
4
tests/parameters/fixtures/node-label004.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
parameters:
|
||||
- label:
|
||||
name: EXAMPLE LABEL 4
|
||||
description: "EXAMPLE LABEL DESCRIPTION 4"
|
Loading…
x
Reference in New Issue
Block a user