I have following script
def Greet(name){
echo "Hello ${name}" // printing output on console as Hello Amol
sh 'ssh -i @hostId "echo Hello ${name}"' // not printing anything on console. print only echo
}
node() {
stage("Hello") {
Greet('Amol')
}
}
How to print the ${name} variable value with ssh command. Can someone please help
In the
shcommand, I've replaced the single quotes(')with double quotes(")to allow variable interpolation. I've also escaped the$character beforenameusing a backslash(\)to prevent Jenkins from trying to interpolate thenamevariable locally. For example like this