jenkinsci / jenkinsci/nodelabelparameter-plugin
[JENKINS-43720] NodeLabel parameters are null objects in pipeline script params
- Dominant language
- Java
- Stars
- 28
- Forks
- 59
- Avg merge
- 1h 24m
- Merged PRs (30d)
- 3
Description
Accessing the parameter with param will give you a null object, but accessing it through env and global will give you the string of one node.
Example:
properties ([
parameters([
[
$class: 'BooleanParameterDefinition',
defaultValue: false,
description: 'This will do a clean and build of the project.',
name: 'Rebuild'
],
[
$class: 'NodeParameterDefinition',
allowedSlaves: ['ALL (no restriction)'],
defaultSlaves: ['master'],
description: 'What nodes to run the build on.',
name: 'NODE_PARAM',
nodeEligibility: [$class: 'AllNodeEligibility'],
triggerIfResult: 'allowMultiSelectionForConcurrentBuilds'
]
])
])echo "NODE_PARAM: " + NODE_PARAM.getClass().toString()
echo "env.NODE_PARAM: " + env.NODE_PARAM.getClass().toString()
echo "params.NODE_PARAM: " + params.NODE_PARAM.getClass().toString()
Will give you this output:
[Pipeline] echo
NODE_PARAM: class java.lang.String
[Pipeline] echo
env.NODE_PARAM: class java.lang.String
[Pipeline] echo
params.NODE_PARAM: class org.codehaus.groovy.runtime.NullObject
As you can see, only params.NODE_PARAM is null.
The problem is that I can not use env.NODE_PARAM or NODE_PARAM to get multiple selection of nodes, as those are only a string representation of a single node.
---
Originally reported by
snellingen, imported from: NodeLabel parameters are null objects in pipeline script params
Raw content of original issue
Accessing the parameter with param will give you a null object, but accessing it through env and global will give you the string of one node.
Example:
properties ([
parameters([
[
$class: 'BooleanParameterDefinition',
defaultValue: false,
description: 'This will do a clean and build of the project.',
name: 'Rebuild'
],
[
$class: 'NodeParameterDefinition',
allowedSlaves: ['ALL (no restriction)'],
defaultSlaves: ['master'],
description: 'What nodes to run the build on.',
name: 'NODE_PARAM',
nodeEligibility: [$class: 'AllNodeEligibility'],
triggerIfResult: 'allowMultiSelectionForConcurrentBuilds'
]
])
])echo "NODE_PARAM: " + NODE_PARAM.getClass().toString()
echo "env.NODE_PARAM: " + env.NODE_PARAM.getClass().toString()
echo "params.NODE_PARAM: " + params.NODE_PARAM.getClass().toString()Will give you this output:
[Pipeline] echo
NODE_PARAM: class java.lang.String
[Pipeline] echo
env.NODE_PARAM: class java.lang.String
[Pipeline] echo
params.NODE_PARAM: class org.codehaus.groovy.runtime.NullObjectAs you can see, only params.NODE_PARAM is null.
The problem is that I can not use env.NODE_PARAM or NODE_PARAM to get multiple selection of nodes, as those are only a string representation of a single node.
environment
```
Jenkins ver. 2.15 on Windows,
NodeLabel 1.7.2,
Pipeline: Groovy 2.29
```
Contributor guide
Research direction
Start with the nodelabelparameter-plugin's NodeParameterDefinition and its Pipeline: Groovy parameter handling, using the reported params.NODE_PARAM, env.NODE_PARAM, and NODE_PARAM behavior as the reproduction. Trace how multiple selected nodes are represented and verify that params exposes the selection rather than a null object while preserving existing single-node behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- ci-cd, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100