同时使用并行管道在 shell 脚本中获取退出代码 3。
stage('Core:Restart')
{ agent { label "master" }
steps {
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password: "${password}"]]])
{ sh label: '',
script: '''#!/bin/bash
if [[ -z ${CORE_BRANCH} ]] then
echo "You have entered empty branch for CORE Module"
else
for ip in ${CORE_SERVER_IP//,/ }; do
echo "$ip"
sshpass -p $password ssh -o StrictHostKeyChecking=no -tt ${USER}@${ip} <<EOF
set -e
sudo -i
set -e
/etc/init.d/tomcat status
exit 0
exit 0
EOF
done
fi'''
}
}
}
分享以下快照作为额外参考。 Jenkins option