Skip to content

Commit

Permalink
[MOL-14987][BC] Set retry limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedict committed Mar 12, 2024
1 parent 01d8236 commit 7c0ff80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/trigger-gitlab-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ jobs:
echo "[ Running pipline check after $SLEEP_DURATION_MINUTES minutes ]"
sleep $(($SLEEP_DURATION_MINUTES*60))
retry=1
job_status=""
until [[ $job_status == "success" || $job_status == "failed" || $job_status == "canceled" || $job_status == "skipped" ]]
until [[ $retry -gt 5 || $job_status == "success" || $job_status == "failed" || $job_status == "canceled" || $job_status == "skipped" ]]
do
echo "Attempt: $retry"
downstream_pipeline_id=$(curl -sS --request GET --header "PRIVATE-TOKEN: $GITLAB_PAT" \
--url "$GITLAB_ENDPOINT/$GITLAB_PROJECT_ID/pipelines/$PIPELINE_ID/bridges" \
| jq -r '[ .[] | select( .name | contains("'"$DOWNSTREAM_PIPELINE_NAME"'")) ]' | jq -r '.[].downstream_pipeline.id')
Expand All @@ -85,9 +88,14 @@ jobs:
| jq -r '[ .[] | select( .name | contains("'"$DOWNSTREAM_JOB_NAME"'")) ]' | jq -r '.[].status')
echo "($DOWNSTREAM_JOB_NAME) Job status: $job_status"
[[ $job_status == "running" ]] && sleep $(($CHECK_INTERVAL_MINUTES*60))
if [[ $job_status == "running" ]]; then
retry=$((retry+1))
sleep $(($CHECK_INTERVAL_MINUTES*60))
fi
done
[[ $retry -gt 5 ]] && echo "Number of retries exceeded, please head to the GitLab job to check what happened" && exit 1
[[ $job_status == "canceled" ]] && echo "GitLab job was cancelled"
[[ $job_status == "skipped" ]] && echo "GitLab job has stopped, please head to the GitLab job to trigger job manually"
Expand Down

0 comments on commit 7c0ff80

Please sign in to comment.