File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- # Exit script when any executed command return non-zero code.
4- set -e
5-
63# Exit script if you try to use an uninitialized variable.
74set -o nounset
85
96# Use the error status of the first failure, rather than that of the last item in a pipeline.
107set -o pipefail
118
12- trap ' s=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
13-
9+ trap ' s=$?; echo -e >&2 "\nError in $0:\nat line "$LINENO": $BASH_COMMAND"; exit $s' ERR
1410
11+ date
1512counter=0
1613
1714# Wait up to 25 minutes for job to finish. A job can run on multiple nodes: parallelism > 1
1815while [ " $counter " -le 1500 ]; do
19- # Find number of nodes in running
20- job_detail=$( curl -s " https://circleci.com/api/v2/project/github/DataBiosphere/terra-ui/job/$CIRCLE_BUILD_NUM " )
21- job_running_nodes_count=$( echo " $job_detail " | jq -r ' .parallel_runs[] | select(.status == "running") | select(.index != ' " $CIRCLE_NODE_INDEX " ' )' | grep -c " running" )
22-
23- if [ " $job_running_nodes_count " -eq 0 ]; then
24- exit 0
16+ # Find number of nodes in running or queued
17+ build_detail=$( curl -s " https://circleci.com/api/v2/project/github/DataBiosphere/terra-ui/job/$CIRCLE_BUILD_NUM " )
18+
19+ running_vm=$( echo " $build_detail " | jq -r --arg INDX " $CIRCLE_NODE_INDEX " ' .parallel_runs[] | select(.status=="running") | select(.index|tostring!=$INDX)' )
20+ count=$( echo " $running_vm " | grep -c -e " running" || test $? = 1; )
21+ if [ " $count " -eq 0 ]; then
22+ echo " Parallel runs have finished. Exiting wait-for-job-finish script."
23+ exit 0
2524 fi
2625
26+ echo " Waiting for parallel runs to finish..."
2727 sleep 10
2828 counter=$(( $counter + 10 ))
2929done
3030
3131echo " Waited total $counter seconds"
32- date
3332
3433# Something is wrong. Log response for error troubleshooting
3534curl -s " https://circleci.com/api/v2/project/github/DataBiosphere/terra-ui/job/$CIRCLE_BUILD_NUM " | jq -r ' .'
You can’t perform that action at this time.
0 commit comments