-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins LTS 2.46.3
Pipeline v2.5
According to the Jenkins docs, one should be able to define getters and setters for global variables in shared pipeline scripts to manipulating fields. This does not seem to work correctly. Take the following example which is a slight variation on the example from the docs:
// tmp_shared/vars/acme.groovy def setName(value) { echo "Setting name to $value" this.@name = value } def getName() { echo "Getting name of " + this.@name return this.@name }
// Pipeline script @Library ('tmp_shared') _ acme.name = 'Alice' // should print "Setting name to Alice" to the console def tmp = acme.name // should print "Getting name of Alice" to the console
I'd expect the output from this simple test to look something like this:
... Setting name to Alice Getting name of Alice ...
However I see no console output whatsoever. This indicates that the getter and setter methods are not being invoked at all when defined in the Groovy vars scripts for a shared pipeline library.
- relates to
-
JENKINS-31484 Endless loop in DefaultInvoker.getProperty when accessing field via getter/setter without @
- Resolved
-
JENKINS-38021 Accessing unset global variable cause master to hang
- Resolved