From ae6bcadce1b06f8d9ef365748c417e8e77e42b96 Mon Sep 17 00:00:00 2001 From: Zelin Hao Date: Thu, 25 Jan 2024 11:19:34 -0800 Subject: [PATCH] Update the URL for latest index.json in retrievePreviousBuild library (#367) Signed-off-by: Zelin Hao --- build.gradle | 2 +- vars/retrievePreviousBuild.groovy | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 861029a4d..e319350b0 100644 --- a/build.gradle +++ b/build.gradle @@ -121,7 +121,7 @@ jacocoTestReport { } } -String version = '6.1.0' +String version = '6.1.1' task updateVersion { doLast { diff --git a/vars/retrievePreviousBuild.groovy b/vars/retrievePreviousBuild.groovy index 29572d8fd..c72a73f6d 100644 --- a/vars/retrievePreviousBuild.groovy +++ b/vars/retrievePreviousBuild.groovy @@ -30,11 +30,23 @@ void call(Map args = [:]) { def DISTRIBUTION_BUILD_NUMBER if (previousBuildId.equalsIgnoreCase("latest")) { - DISTRIBUTION_BUILD_NUMBER = sh( - script: "curl -sL https://ci.opensearch.org/ci/dbc/${DISTRIBUTION_JOB_NAME}/${version}/index.json | jq -r \".latest\"", - returnStdout: true - ).trim() - //Once we have new index.json, URL will be changed to: https://ci.opensearch.org/ci/dbc/${DISTRIBUTION_JOB_NAME}/${version}/index/${platform}/${architecture}/${distribution}/index.json + def latestIndexStatus = sh ( + script: "curl -sL ${PUBLIC_ARTIFACT_URL}/${DISTRIBUTION_JOB_NAME}/${version}/index/${DISTRIBUTION_PLATFORM}/${DISTRIBUTION_ARCHITECTURE}/${distribution}/index.json | jq -r \".latest\" > /dev/null 2>&1", + returnStatus: true + ) + if (latestIndexStatus == 0) { + echo("Use new URL path for the latest index.") + DISTRIBUTION_BUILD_NUMBER = sh( + script: "curl -sL ${PUBLIC_ARTIFACT_URL}/${DISTRIBUTION_JOB_NAME}/${version}/index/${DISTRIBUTION_PLATFORM}/${DISTRIBUTION_ARCHITECTURE}/${distribution}/index.json | jq -r \".latest\"", + returnStdout: true + ).trim() + } else { + echo("Use old URL path for the latest index.") + DISTRIBUTION_BUILD_NUMBER = sh( + script: "curl -sL ${PUBLIC_ARTIFACT_URL}/${DISTRIBUTION_JOB_NAME}/${version}/index.json | jq -r \".latest\"", + returnStdout: true + ).trim() + } } else { DISTRIBUTION_BUILD_NUMBER = previousBuildId }