Add 'node' parameter to 'parameters'
This parameter defines a list of nodes where this job could potentially be executed on. Nodes can be choosen from list of current available nodes. Currently it trasforms to single-selection dropdown to choose a slave for execution. Change-Id: I5379d20b94e3b33360ea8f842e3b4237b491addb
This commit is contained in:
parent
084eb8122f
commit
b542685244
@ -171,6 +171,47 @@ def label_param(parser, xml_parent, data):
|
||||
'LabelParameterDefinition')
|
||||
|
||||
|
||||
def node_param(parser, xml_parent, data):
|
||||
"""yaml: node
|
||||
Defines a list of nodes where this job could potentially be executed on.
|
||||
Restrict where this project can be run, If your using a node or label
|
||||
parameter to run your job on a particular node, you should not use the
|
||||
option "Restrict where this project can be run" in the job configuration
|
||||
- it will not have any effect to the selection of your node anymore!
|
||||
|
||||
:arg str name: the name of the parameter
|
||||
:arg str description: a description of the parameter (optional)
|
||||
:arg list default-nodes: The nodes used when job gets triggered
|
||||
by anything else other than manually
|
||||
:arg list allowed-slaves: The nodes available for selection
|
||||
when job gets triggered manually. Empty means 'All'.
|
||||
:arg bool ignore-offline-nodes: Ignore nodes not online or not having
|
||||
executors (default false)
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/parameters/fixtures/node-param001.yaml
|
||||
:language: yaml
|
||||
|
||||
"""
|
||||
pdef = base_param(parser, xml_parent, data, False,
|
||||
'org.jvnet.jenkins.plugins.nodelabelparameter.'
|
||||
'NodeParameterDefinition')
|
||||
default = XML.SubElement(pdef, 'defaultSlaves')
|
||||
if 'default-slaves' in data:
|
||||
for slave in data['default-slaves']:
|
||||
XML.SubElement(default, 'string').text = slave
|
||||
allowed = XML.SubElement(pdef, 'allowedSlaves')
|
||||
if 'allowed-slaves' in data:
|
||||
for slave in data['allowed-slaves']:
|
||||
XML.SubElement(allowed, 'string').text = slave
|
||||
XML.SubElement(pdef, 'ignoreOfflineNodes').text = str(
|
||||
data.get('ignore-offline-nodes', False)).lower()
|
||||
|
||||
XML.SubElement(pdef, 'triggerIfResult').text = \
|
||||
'multiSelectionDisallowed'
|
||||
|
||||
|
||||
def choice_param(parser, xml_parent, data):
|
||||
"""yaml: choice
|
||||
A single selection parameter.
|
||||
|
@ -99,6 +99,7 @@ jenkins_jobs.parameters =
|
||||
file=jenkins_jobs.modules.parameters:file_param
|
||||
label=jenkins_jobs.modules.parameters:label_param
|
||||
matrix-combinations=jenkins_jobs.modules.parameters:matrix_combinations_param
|
||||
node=jenkins_jobs.modules.parameters:node_param
|
||||
password=jenkins_jobs.modules.parameters:password_param
|
||||
run=jenkins_jobs.modules.parameters:run_param
|
||||
string=jenkins_jobs.modules.parameters:string_param
|
||||
|
21
tests/parameters/fixtures/node-param001.xml
Normal file
21
tests/parameters/fixtures/node-param001.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterDefinition>
|
||||
<name>SLAVE_NAME</name>
|
||||
<description>Select slave</description>
|
||||
<defaultSlaves/>
|
||||
<allowedSlaves>
|
||||
<string>slave001</string>
|
||||
<string>slave002</string>
|
||||
<string>slave003</string>
|
||||
</allowedSlaves>
|
||||
<ignoreOfflineNodes>true</ignoreOfflineNodes>
|
||||
<triggerIfResult>multiSelectionDisallowed</triggerIfResult>
|
||||
</org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
</project>
|
10
tests/parameters/fixtures/node-param001.yaml
Normal file
10
tests/parameters/fixtures/node-param001.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
parameters:
|
||||
- node:
|
||||
name: SLAVE_NAME
|
||||
description: "Select slave"
|
||||
allowed-slaves:
|
||||
- slave001
|
||||
- slave002
|
||||
- slave003
|
||||
ignore-offline-nodes: true
|
||||
|
Loading…
Reference in New Issue
Block a user