After updating to Jenkins 2.492.2 I’ve started to see warnings in my pipeline console similar to, “Did you forget the def
keyword? WorkflowScript seems to be setting a field named {variableName} (to a value of type Integer) which could lead to memory leaks or other issues..”. Nothing has changed in my pipeline script, and as far as I know I’m not doing anything unusual in the pipeline. It looks similar to…
MyGlobalVariable = 69
pipeline {
agent {
label 'master'
}
stages {
stage('First Stage') {
agent { label 'master }
steps {
script {
println("My Variable = ${MyGlobalVariable}")
}
}
}
}
}
I’ve tried putting ‘def’ before the global variable, but that causes an error when I try to access the variable (groovy.lang.MissingPropertyException: No such property).
Why am I seeing this warning after upgrading, and how can I resolve it?