我已经编写了一个Jenkins文件,并且在一步中我被卡住了,这基本上就是部署阶段。在部署阶段,有一个步骤,我必须ssh到一个服务器并运行几个命令。之前它工作正常,但是当我用一些正则表达式添加sed命令时,Jenkins显示语法错误。以下是摘录。
steps {
sshagent ( credentials: []) {
sh '''
echo "Tag=miqp-server_${BUILD_NUMBER}" > sshenv
echo "target=${DeployTo}" >> sshenv
scp sshenv root@SERVERIP:~/.ssh/environment
ssh -T -o StrictHostKeyChecking=no -l root SERVERIP <<'EOF'
#DEPLOYMENT_NAME="miqp-server-dep"
#CONTAINER_NAME="miqp-server-dev"
#NEW_DOCKER_IMAGE="2xxxxxxxxxx6.dkr.ecr.us-east-1.amazonaws.com/miqp-devops:${Tag}"
RELEASE_NAME=miqp-server-dep
if [ "${target}" = "None" ]
then
echo "No deployment to K8s"
else
cd /root/kubernetes-ingress/dev/miqp-server-dep/
sed -i "s/^\([[:space:]]*tag:[[:space:]]*\).*/\1$Tag/" values.yaml
helm upgrade -f values.yaml $RELEASE_NAME miqp-server-dep.0.1.0.tgz
#kubectl set image deployment/$DEPLOYMENT_NAME $CONTAINER_NAME=$NEW_DOCKER_IMAGE -n devops-dev
#kubectl rollout status deployment $DEPLOYMENT_NAME -n devops-dev
fi
EOF'''
Jenkins抛出的错误是
WorkflowScript: 156: unexpected char: '\' @ line 156, column 13.
sed -i "s/^\([[:space:]]*tag:[[:space:]]*\).*/\1$Tag/" values.yaml
^
1 error
答案 0 :(得分:0)
嘿,我通过提供转义字符
解决了这个问题const styles = {
id5248698745: {
button: {
backgroundColor: 'green'
},
label: {
color: 'yellow',
fontSize: 18
},
paragraph: {
color: 'red',
fontSize: 19
},
headings: {
color: 'wihte',
fontSize: 24
}
}
};
// ...
render() {
const {style, theme} = this.props;
return <Button {...this.props} style={[style, styles[theme].button]} />
}
// ...
// <Button theme={this.props.themeId} {/* other Button component props */} />
谢谢