Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gradle-check script to wait for workflow_url to be ready #4993

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions scripts/gradle/gradle-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,39 @@ echo "wait for jenkins to start workflow" && sleep 15

echo "Check if queue exist in Jenkins after triggering"
if [ -z "$QUEUE_URL" ] || [ "$QUEUE_URL" != "null" ]; then
WORKFLOW_URL=$(curl -s -XGET ${JENKINS_URL}/${QUEUE_URL}api/json | jq --raw-output .executable.url)
echo WORKFLOW_URL $WORKFLOW_URL

echo "Use queue information to find build number in Jenkins if available"
if [ -z "$WORKFLOW_URL" ] || [ "$WORKFLOW_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"
echo "Jenkins Workflow Url: $WORKFLOW_URL"
TIMEPASS=$(( TIMEPASS + 30 )) && echo time pass: $TIMEPASS
sleep 30
RUNNING=$(perform_curl_and_process_with_jq "$WORKFLOW_URL" ".building" 10)
echo "Workflow running status :$RUNNING"
done

if [ "$RUNNING" = "true" ]; then
echo "Timed out"
RESULT="TIMEOUT"
while [ "$RESULT" = "null" ] && [ "$TIMEPASS" -le "$TIMEOUT" ]; do
WORKFLOW_URL=$(curl -s -XGET ${JENKINS_URL}/${QUEUE_URL}api/json | jq --raw-output .executable.url)
echo WORKFLOW_URL $WORKFLOW_URL

echo "Use queue information to find build number in Jenkins if available"
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
if [ -n "$WORKFLOW_URL" ] || [ "$WORKFLOW_URL" != "null" ]; then
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved

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"
echo "Jenkins Workflow Url: $WORKFLOW_URL"
TIMEPASS=$(( TIMEPASS + 30 )) && echo time pass: $TIMEPASS
sleep 30
RUNNING=$(perform_curl_and_process_with_jq "$WORKFLOW_URL" ".building" 10)
echo "Workflow running status :$RUNNING"
done

if [ "$RUNNING" = "true" ]; then
echo "Timed out"
RESULT="TIMEOUT"
else
echo "Complete the run, checking results now......"
RESULT=$(curl -s -XGET ${WORKFLOW_URL}api/json | jq --raw-output .result)
fi

else
echo "Complete the run, checking results now......"
RESULT=$(curl -s -XGET ${WORKFLOW_URL}api/json | jq --raw-output .result)
echo "Job not started yet. Waiting for 60 seconds before next attempt."
TIMEPASS=$(( TIMEPASS + 60 )) && echo time pass: $TIMEPASS
sleep 60
fi

fi
done
fi

echo "Please check jenkins url for logs: $WORKFLOW_URL"
Expand Down
Loading