我在Jenkins管道中运行了这个Shell脚本
def planResults = sh(returnStdout: true, script: "cd $it; PLAN=\$(terragrunt plan --terragrunt-source-update | landscape); echo "$PLAN"; CHANGES=$(echo "$PLAN" | tail -2); echo $CHANGES")
Run Code Online (Sandbox Code Playgroud)
问题是当我尝试回显“ $ PLAN”变量时。
这是groovy推荐的解决方案,它可以在PLAN设置为\ $(terragrunt的位置附近使用,但是对于$内的双引号不起作用。我需要双引号才能使此命令正常工作。
solution: either escape a literal dollar sign "\$5" or bracket the value
expression "${5}" @ line 34, column 148.
ce-update | landscape); echo "$PLAN"; CH
Run Code Online (Sandbox Code Playgroud)
谢谢!