Allow running only on one of nodes with label parameter

Current default value setting makes the jobs with label parameter
execute in parallel on all nodes matching a label. In some cases that is
not expected and is undesirable. It is also no the default value
upstream

Change-Id: Idf3460f165209611113193c7e85a884c42511371
This commit is contained in:
Aigars Mahinovs 2018-08-09 16:40:58 +02:00
parent 8ab1c56b09
commit 07a059d270
3 changed files with 25 additions and 2 deletions

View File

@ -190,6 +190,8 @@ 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 bool all-nodes: to run job on all nodes matching label
in parallel (default: true)
: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
@ -206,10 +208,9 @@ def label_param(registry, xml_parent, data):
'org.jvnet.jenkins.plugins.nodelabelparameter.'
'LabelParameterDefinition')
XML.SubElement(pdef, 'allNodesMatchingLabel').text = "true"
valid_types = ['allCases', 'success', 'unstable']
mapping = [
('all-nodes', 'allNodesMatchingLabel', True),
('matching-label', 'triggerIfResult', 'allCases', valid_types),
]
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)

View 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>false</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>

View File

@ -0,0 +1,5 @@
parameters:
- label:
name: EXAMPLE LABEL 4
description: "EXAMPLE LABEL DESCRIPTION 4"
all-nodes: false