在声明性管道内的Shell脚本中传递Jenkins参数值时出现错误的替换错误 [英] Bad Substitution error while passing Jenkins Parameter value in shell script inside Declarative pipeline

查看:124
本文介绍了在声明性管道内的Shell脚本中传递Jenkins参数值时出现错误的替换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,我正在Jenkins声明性管道中传递参数值,但是当我执行此错误时

Here is my code which I am passing parameter value in my Jenkins Declarative Pipeline, but when I execute getting this error

T@tmp/durable-64ccbb6b/script.sh:第4行:$ {params.InputValue}:错误替换

                  sh '''
                  #!/bin/bash -xe
                  printf '%s\n' /dev/sd{e..z} | head -n "${params.InputValue}" > volumelist.txt
                  cat volumelist.txt
                  '''

我几乎尝试了所有Google搜索中的错误替换.仍然不能摆脱它.有人可以帮我解决这个问题吗?

I tried almost all of google searches for Bad substitution. Still can't get rid of it. Could someone help me out how to resolve this??

推荐答案

看看Groovy的字符串插值.

tl; dr使用''," 代替''':

tl;dr Use """ instead of ''':

sh """
  printf ${params.InputValue}
"""

这篇关于在声明性管道内的Shell脚本中传递Jenkins参数值时出现错误的替换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆