Jenkins Pipeline从Shell脚本/命令获取输出,并根据if else条件运行下游作业
示例:-
stage 'stage1'
node {
build job: 'build_test'
}
我希望在检查“ git rev-parse HEAD”和lastSuccessful日志输出是否不相同之后执行下游作业。
例如在shell脚本中
#!/bin/bash
set +x
JOB_NAME="build_test"
cd /var/lib/jenkins/workspace/$JOB_NAME
SuccVer=`cat /var/lib/jenkins/jobs/$JOB_NAME/lastSuccessful/log |grep -a Revision |awk '{print $4}'`
ver=`git rev-parse HEAD`
if [ "$SuccVer" = "$ver" ]
then
echo "Successful"
else
echo "not Successful"
fi
常规用法相同