From eabaadd4b33ce199e97dd99cd66710b1858fd469 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 13 Jan 2025 14:27:03 +0100 Subject: [PATCH] Some bugs --- .github/workflows/build-any-ib.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-any-ib.yml b/.github/workflows/build-any-ib.yml index ed721090..83286ea8 100644 --- a/.github/workflows/build-any-ib.yml +++ b/.github/workflows/build-any-ib.yml @@ -56,6 +56,7 @@ jobs: steps: - name: Launch the build-any-ib job in Jenkins and wait for completion run: | + set -euo pipefail # Login against SSO TOKEN="$(curl --location -X POST "$SSO_AUTH_URL" \ --header 'Content-Type: application/x-www-form-urlencoded' \ @@ -69,11 +70,20 @@ jobs: -H "Authorization: Bearer $TOKEN" \ --data "PACKAGE_NAME=$PACKAGE_NAME" \ --data "ALIDIST_SLUG=$ALIDIST_SLUG" \ - --data "ARCHITECTURE=$ARCHITECTURE") + --data "ARCHITECTURE=$ARCHITECTURE") | grep -i "Location:" | awk '{print $2}' | tr -d '\r') + + # Remove any trailing whitespace, change http to https + QUEUE_URL=$(echo "$QUEUE_URL" | xargs) + QUEUE_URL=$(echo "$QUEUE_URL" | sed 's/http/https/') + + if [ -z "$QUEUE_URL" ]; then + echo "::error::Failed to get queue URL from Jenkins" + exit 1 + fi # Poll the queue item until we get the actual job URL while true; do - QUEUE_RESPONSE=$(curl -s "$QUEUE_URL/api/json" -H "Authorization: Bearer $TOKEN") + QUEUE_RESPONSE=$(curl -L -s "$QUEUE_URL/api/json" -H "Authorization: Bearer $TOKEN") if echo "$QUEUE_RESPONSE" | jq -e '.executable.url' > /dev/null; then BUILD_URL=$(echo "$QUEUE_RESPONSE" | jq -r '.executable.url') break @@ -84,6 +94,8 @@ jobs: echo "Job started at: $BUILD_URL" + BUILD_URL=$(echo "$BUILD_URL" | sed 's/alijenkins/alijenkins-api/') + while true; do JOB_STATUS=$(curl -s "$BUILD_URL/api/json" -H "Authorization: Bearer $TOKEN" | jq -r '.result') if [ "$JOB_STATUS" = "SUCCESS" ]; then