-
Bug
-
Resolution: Won't Fix
-
Major
In a pipeline stage, it is not possible to reference a variable that is set inside a shell script as part of a former stage, see the simplified example below. In my use case, the first stage reads a file in the workspace and evaluates part of its content to set the variable.
stage 'Fetch version' sh '''#!/bin/sh version=abc''' stage 'Second' sh "${mvnHome}/bin/mvn -f all/pom.xml -Dversion=$version ...
Result:
groovy.lang.MissingPropertyException: No such property: version for class: WorkflowScript
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:25)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:17)
at WorkflowScript.run(WorkflowScript:48)
I've tried a lot of different things setting and accessing the variable, including the environment variable env, but nothing worked.