-
Task
-
Resolution: Unresolved
-
Critical
-
None
for more complex variables that are annotated with @Field, the load step fails to bind the variable into the Script class.
For example:
// a.groovy import groovy.transform.Field @Field def LOADED_BUILD_NUMBER = ${env.BUILD_NUMBER} return this // Jenkinsfile node() { def a = load('a.groovy') echo(${env.BUILD_NUMBER}) echo(${a.LOADED_BUILD_NUMBER}) }
This example will fail. However, if you replace ${env.BUILD_NUMBER} with a simple type such as `3`, the load step will succeed.
This seems to be related to the security update in workflow-cps v2.64 and the subsequent regression fix for @Field in v2.71.
[JENKINS-63384] load step fails to bind "complex" @Field defined variables
Description |
Original:
for more complex variables that are annotated with @Field, the load step fails to bind the variable into the Script class. For example: {code:java} // a.groovy import groovy.transform.Field @Field def LOADED_BUILD_NUMBER = ${env.BUILD_NUMBER} return this // Jenkinsfile node() { def a = load('a.groovy') echo(${env.BUILD_NUMBER}) echo(${a.LOADED_BUILD_NUMBER}) } {code} {{}} This example will fail. However, if you replace ${env.BUILD_NUMBER} with a simple type such as `3`, the load step will succeed. This seems to be related to the security update in workflow-cps v2.64 and the subsequent regression fix for @Field in v2.71. |
New:
for more complex variables that are annotated with @Field, the load step fails to bind the variable into the Script class. For example: {code:java} // a.groovy import groovy.transform.Field @Field def LOADED_BUILD_NUMBER = ${env.BUILD_NUMBER} return this // Jenkinsfile node() { def a = load('a.groovy') echo(${env.BUILD_NUMBER}) echo(${a.LOADED_BUILD_NUMBER}) } {code} This example will fail. However, if you replace ${env.BUILD_NUMBER} with a simple type such as `3`, the load step will succeed. This seems to be related to the security update in workflow-cps v2.64 and the subsequent regression fix for @Field in v2.71. |
Priority | Original: Minor [ 4 ] | New: Critical [ 2 ] |
These "security" fixes start driving me crazy.
There seems to be no way to preserve the state across Jenkins restarts anymore in my library.
None of the classical Java singleton patterns (that relies on static fields) work because CPS does not serialize static fields.
`@Singleton` annotation doesn't work because AST transformation will define a `getInstance()` method without `@NonCPS` annotation making this singleton unusable from my `@NonCPS` annotated code.
Now this - I can't preserve state as a global var `@Field` anymore.
Really starting to feel like the whole objective here is to make user's life harder...