From f6564cac54dafaa30b46ce3cfdcdd772fa823827 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 4 Sep 2024 14:46:40 -0400 Subject: [PATCH 1/5] Update gradle-check script to wait for workflow_url to be ready Signed-off-by: Peter Zhu --- scripts/gradle/gradle-check.sh | 55 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/scripts/gradle/gradle-check.sh b/scripts/gradle/gradle-check.sh index 33632340f5..2f06ae64c5 100755 --- a/scripts/gradle/gradle-check.sh +++ b/scripts/gradle/gradle-check.sh @@ -66,33 +66,38 @@ 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 [ "$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" + if [ -n "$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" + 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." + sleep 60 fi - - fi + done fi echo "Please check jenkins url for logs: $WORKFLOW_URL" From e07e004772727473c0d2d49ea85293b58a30ae5d Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 4 Sep 2024 14:51:42 -0400 Subject: [PATCH 2/5] Update gradle-check script to wait for workflow_url to be ready Signed-off-by: Peter Zhu --- scripts/gradle/gradle-check.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/gradle/gradle-check.sh b/scripts/gradle/gradle-check.sh index 2f06ae64c5..caead10174 100755 --- a/scripts/gradle/gradle-check.sh +++ b/scripts/gradle/gradle-check.sh @@ -66,7 +66,7 @@ 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 - while [ "$TIMEPASS" -le "$TIMEOUT" ]; do + 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 @@ -95,6 +95,7 @@ if [ -z "$QUEUE_URL" ] || [ "$QUEUE_URL" != "null" ]; then else echo "Job not started yet. Waiting for 60 seconds before next attempt." + TIMEPASS=$(( TIMEPASS + 60 )) && echo time pass: $TIMEPASS sleep 60 fi done From 2d027efa6596773002114fd52df460f7a29d4300 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 4 Sep 2024 14:54:47 -0400 Subject: [PATCH 3/5] Small tweaks Signed-off-by: Peter Zhu --- scripts/gradle/gradle-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gradle/gradle-check.sh b/scripts/gradle/gradle-check.sh index caead10174..8f97d44900 100755 --- a/scripts/gradle/gradle-check.sh +++ b/scripts/gradle/gradle-check.sh @@ -66,7 +66,7 @@ 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 - while [ "$RESULT" == "null" ] && [ "$TIMEPASS" -le "$TIMEOUT" ]; do + 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 From ac1fdeab2c40c1c9a98a36b84c50e5847bb2fe3e Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 4 Sep 2024 15:03:34 -0400 Subject: [PATCH 4/5] Address the comment Signed-off-by: Peter Zhu --- scripts/gradle/gradle-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gradle/gradle-check.sh b/scripts/gradle/gradle-check.sh index 8f97d44900..0e56f6011e 100755 --- a/scripts/gradle/gradle-check.sh +++ b/scripts/gradle/gradle-check.sh @@ -67,10 +67,10 @@ 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 while [ "$RESULT" = "null" ] && [ "$TIMEPASS" -le "$TIMEOUT" ]; do + echo "Use queue information to find build number in Jenkins if available" 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 [ -n "$WORKFLOW_URL" ] || [ "$WORKFLOW_URL" != "null" ]; then RUNNING="true" From 5eb19788717761231a04c083b48bad6a1bc86388 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 4 Sep 2024 15:16:38 -0400 Subject: [PATCH 5/5] Tweak small changes Signed-off-by: Peter Zhu --- scripts/gradle/gradle-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gradle/gradle-check.sh b/scripts/gradle/gradle-check.sh index 0e56f6011e..7b5a29d2aa 100755 --- a/scripts/gradle/gradle-check.sh +++ b/scripts/gradle/gradle-check.sh @@ -71,7 +71,7 @@ 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 - if [ -n "$WORKFLOW_URL" ] || [ "$WORKFLOW_URL" != "null" ]; then + if [ -n "$WORKFLOW_URL" ] && [ "$WORKFLOW_URL" != "null" ]; then RUNNING="true"