-
-
Save KyMidd/a45fb82e09e503de1849a3779f355456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while [ i = i ]; do | |
# Check job status | |
echo "Query Build Job Status" | |
BUILDING=$(curl -s -X GET -u "$userName:$api_token" "${urlOfJenkinsServer}/job/${jenkinsJobName}/api/json?depth=10&tree=builds\[queueId,id,building,result,url\]&pretty=true" | jq -r ".builds[] | select(.id==\"$JOBID\") | .building") | |
JOBSTATUS=$(curl -s -X GET -u "$userName:$api_token" "${urlOfJenkinsServer}/job/${jenkinsJobName}/api/json?depth=10&tree=builds\[queueId,id,building,result,url\]&pretty=true" | jq -r ".builds[] | select(.id==\"$JOBID\") | .result") | |
if [ "$JOBSTATUS" == "null" ]; then | |
# Job is still building | |
echo "Job is still building: ${BUILDING}" | |
else | |
# If JOBSTATUS populated, it has finished. Break and exit watch loop | |
break | |
fi | |
# Wait pollTime seconds | |
echo "Jenkins still working hard, sleeping for ${pollTime} seconds" | |
echo "--------------------------------------" | |
sleep $pollTime | |
currentTimeSeconds=$(date +%s) | |
if [[ "$currentTimeSeconds" > "$finishTimeInSeconds" ]]; then | |
echo "Timeout value reached. Exiting with error due to timeout" | |
echo "--------------------------------------" | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment