gpt4 book ai didi

Jenkins 文件 : illegal string body character after dollar sign; solution: either escape a literal dollar sign "\$5" or bracket the value expression

转载 作者:行者123 更新时间:2023-12-04 22:18:03 29 4
gpt4 key购买 nike

我的管道在 Jenkinsfile 的 sh """元素处失败。知道哪里出了问题吗?

    stage('Install dependencies') {
when { expression { return params.dependencies } } }
steps {
sh """
apt-get update
apt-get install -y openssh-server net-tools inetutils-ping python-pip rubygems
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -

add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"

apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
gem install serverspec pygmy
"""
}
}

错误信息是:
WorkflowScript: 35: illegal string body character after dollar sign;
solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" @ line 35, column 17.

最佳答案

替换双引号 """带单引号 ''' .

sh '''
apt-get update
//...
'''

每当 Groovy 看到 $在双引号内,它将此字符串视为 GString并且做 string interpolation .但是,就您而言,字符 $不用于插值的上下文中并且它失败。或者,您可以逃避 \$但切换到单引号字符串更有意义。

关于 Jenkins 文件 : illegal string body character after dollar sign; solution: either escape a literal dollar sign "\$5" or bracket the value expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55454137/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com