For the life of me, I can't figure out how to declare and use new variables inside a shell block in a groovy script.
For example, this shell block -
sh """
export earlist='abc.ear,def.ear'
echo $earlist;
"""
throws an error saying
No such property: earlist for class: GroovyUserScript
If I add a def earlist before the sh, then it throws error saying -
No signature of method: GroovyUserScript.sh() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [ export earlist='abc.ear,def.ear' echo ;
Can someone please help me with how to declare and then use variable inside a shell block, in a groovy script?
sh ''' ... '''. or you have to escape$sign:\$. when you use double-quotes groovy tries to substitute$xxxexpressions in string with groovy variable values. - daggett