This code works as expected
file ='fileId'
node {
configFileProvider([configFile(fileId: file, variable: 'propertiesFile'
)]) {
echo "$propertiesFile"
}
}
I tried to move it to class
class Runner implements Serializable {
def steps
Runner(steps) {
this.steps = steps
}
void createParametersYaml() {
steps.node {
steps.configFileProvider([steps.configFile(fileId: file,
variable: 'propertiesFile')]) {
steps.echo "$propertiesFile"
}
}
}
}
new Runner(steps).createParametersYaml()
and get error
groovy.lang.MissingPropertyException: No such property: propertiesFile for
class: Runner
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:243)
at
org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:52)
at
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:308)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at
com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
at
com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at Runner.createParametersYaml(WorkflowScript:15)
at ___cps.transform___(Native Method)
How can I fix this?
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/6cd89888-2c50-4d61-8c1c-11c811490b27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.