Dear All,
I am trying to setup (many) environment variables for a set of stages within a pipeline by reading a property file and then passing the result to withEnv.
As far as my understanding is correct, I thought that withEnv waits for a map, and readProperties returrns a map.
So, I try this :
def localProps=[:]
localProps=["moduleName=Communicator","versionNbr=1.0"]
def pipeProps=readProperties([
defaults : localProps,
file : "Pipeline/lib/tutoFile.properties"
])
echo "${pipeProps}"
withEnv(pipeProps) {
... pipeline stages
}
I am sure that the file is read within pipePros.
But the withEnv step fails with the following error :
java.lang.UnsupportedOperationException: must specify $class with an implementation of interface java.util.List at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:442) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:371) at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:194) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
I don't understand what is wrong in the code (as you can imagine, I am not a groovy guru...), and I'd like to know how to get out of there.
Thanks for your help.
J-L