I have two stages and I want to share the info object with their properties to the second stage
stage("Enter deploy information")
{
options
{
timeout(time: 3, unit: 'MINUTES')
}
steps
{
script
{
env.info = askForDeployInformation()
}
}
}
stage('Get artifact')
{
steps
{
customCopyArtifacts(env.info.BranchName, env.info.BuildNumber)
}
}
But this fails with this error:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.String BranchName
11:56:44 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:425)
11:56:44 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:409)
11:56:44 at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:353)
11:56:44 at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:357)
11:56:44 at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
11:56:44 at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
11:56:44 at WorkflowScript.run(WorkflowScript:24)
11:56:44 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.delegateAndExecute(ModelInterpreter.groovy:137)
How to store "complex" variable in environment?