Skip to content

Commit

Permalink
Improve output on gradle check timeout
Browse files Browse the repository at this point in the history
The result ends up being reported as 'null' when this script times out.
The output never directly indicates that a timeout occurred, so this
commit makes the output more explicit.

Also this uses the built-in bash variable `SECONDS` that tracks
elapsed seconds from the start of the script instead of trying to
compute this manually.

Signed-off-by: Andrew Ross <[email protected]>
  • Loading branch information
andrross committed Nov 16, 2022
1 parent 918ae0d commit 0c9f33d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/gradle/gradle-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


JENKINS_URL="https://build.ci.opensearch.org"
TIMEPASS=0
TIMEOUT=7200
RESULT="null"
TRIGGER_TOKEN=$1
Expand Down Expand Up @@ -45,17 +44,21 @@ if [ -z "$QUEUE_URL" ] || [ "$QUEUE_URL" != "null" ]; then
RUNNING="true"

echo "Waiting for Jenkins to complete the run"
while [ "$RUNNING" = "true" ] && [ "$TIMEPASS" -le "$TIMEOUT" ]; do
echo "Still running, wait for another 30 seconds before checking again, max timeout $TIMEOUT"
while [ "$RUNNING" = "true" ] && [ "$SECONDS" -le "$TIMEOUT" ]; do
echo "Still running, will wait for another 30 seconds before checking again, max timeout ${TIMEOUT}s"
echo "Jenkins Workflow Url: $WORKFLOW_URL"
TIMEPASS=$(( TIMEPASS + 30 )) && echo time pass: $TIMEPASS
echo "Time elapsed: ${SECONDS}s"
sleep 30
RUNNING=$(curl -s -XGET ${WORKFLOW_URL}api/json | jq --raw-output .building)
done

echo "Complete the run, checking results now......"
RESULT=$(curl -s -XGET ${WORKFLOW_URL}api/json | jq --raw-output .result)

if [ "$SECONDS" -le "$TIMEOUT" ]; then
echo "Job is complete, checking results now..."
RESULT=$(curl -s -XGET ${WORKFLOW_URL}api/json | jq --raw-output .result)
else
echo "Timed out after ${SECONDS}s"
RESULT="TIMEOUT"
fi
fi
fi

Expand Down

0 comments on commit 0c9f33d

Please sign in to comment.