我有GitLab Pipeline,它可以远程调用Jenkins作业。但是Gitlab阶段不会等到詹金斯工作完成。
我尝试了以下答案中提到的sh脚本:
Check Jenkins job status after triggering a build remotely
但是为此,我需要禁用Jenkins登录
JOB_URL="http:/MyIpAdress:8080/job/TestPipeline"
JOB_STATUS_URL=${JOB_URL}/lastBuild/api/json
GREP_RETURN_CODE=0
# Start the build
curl $JOB_URL/build?delay=0sec
# Poll every thirty seconds until the build is finished
while [ $GREP_RETURN_CODE -eq 0 ]
do
sleep 30
# Grep will return 0 while the build is running:
curl --silent $JOB_STATUS_URL | grep result\":null > /dev/null
GREP_RETURN_CODE=$?
done
echo Build finished
这是不允许我启用登录的Jenkins实例,它还会在GitLab运行程序中返回很多垃圾内容