-
Bug
-
Resolution: Fixed
-
Major
-
None
-
centos7
Jenkins ver. 2.60.1
Pipeline groovy 2.36.1
Pipeline: Shared Groovy Libraries 2.8
I'm seeing this at least when I load scripts from another - I refer to these as subscripts. My usual pattern is to wrap all the code in there into a class, such as:
class FooSubScript{
final def steps
FooSubScript(steps) {
this.steps = steps
}
....
I've only recently started doing this, to better share code between several scripts. The pattern has been working over the last few weeks but suddenly stopped working, I believe yesterday. I get errors along the lines of:
groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: globals for class: setupSubScript
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2744)
at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3770)
at setupSubScript.setProperty(Script1.groovy)
(in this particular example, the first property was called globals)
As far as I can see that is perfectly valid groovy. Commenting or deleting the final makes it work.
- relates to
-
JENKINS-34599 Static initializers not allowed to set final fields
- Resolved