groovy script - sh with variable
You have to use double quotes instead of single in order to replace expressions in the string:
def COLORnode('nodename'){ stage ('color') { COLOR = "green" echo "color is $COLOR" sh """COLOR=${COLOR} echo $COLOR""" }}
If single quotes need to be used for some reason, try concatenating using +
:
sh '''COLOR=''' + COLOR + ''' echo ''' + COLOR