From e8d520c0118284b27dbd65af58e59305556ca582 Mon Sep 17 00:00:00 2001 From: aweng98 Date: Wed, 15 May 2024 19:43:49 -0400 Subject: [PATCH] update --- .circleci/wait-for-job-finish.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/wait-for-job-finish.sh b/.circleci/wait-for-job-finish.sh index 175fa2201b..018f8f6274 100755 --- a/.circleci/wait-for-job-finish.sh +++ b/.circleci/wait-for-job-finish.sh @@ -13,13 +13,16 @@ counter=0 # Wait up to 25 minutes for job to finish. A job can run on multiple nodes: parallelism > 1 while [ "$counter" -le 1500 ]; do - # Find number of nodes in running or queued - build_detail=$(curl -s "https://circleci.com/api/v2/project/github/DataBiosphere/terra-ui/job/$CIRCLE_BUILD_NUM") + # Find number of nodes in running + job_detail=$(curl -s "https://circleci.com/api/v2/project/github/DataBiosphere/terra-ui/job/$CIRCLE_BUILD_NUM") - running_vm=$(echo "$build_detail" | jq -r --arg INDX "$CIRCLE_NODE_INDEX" '.parallel_runs[] | select(.status=="running") | select(.index|tostring!=$INDX)') + # First, check the response for valid job json + runs=$(echo "$job_detail" | jq -r '.parallel_runs[]') + running_vm=$(echo "$runs" | jq -r 'select(.status=="running")') count=$(echo "$running_vm" | grep -c -e "running" || test $? = 1;) if [ "$count" -eq 0 ]; then echo "Parallel runs have finished. Exiting wait-for-job-finish script." + echo "$runs" exit 0 fi