From 46a64dfa084289129517ce5c96091a8a78ac4a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20J=C3=B3zala?= <377355+jozala@users.noreply.github.com> Date: Thu, 26 Jun 2025 12:57:02 +0200 Subject: [PATCH] Use ES_VERSION to resolve manifest for ML and Beats (#130084) Previously BRANCH was used in all cases, but if there is a newer version of the dependency, the incorrect version could be used. BRANCH is still used for snapshot DRA builds because full version is not available in artifacts-snapshot API. Additionally, added log what URL is used to fetch manifest and make the curl command fail in case of error like 404 response. (cherry picked from commit c05794510dcb5d25de13f1f84ca2d84b2123bbcb) # Conflicts: # .ci/scripts/resolve-dra-manifest.sh --- .ci/scripts/resolve-dra-manifest.sh | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.ci/scripts/resolve-dra-manifest.sh b/.ci/scripts/resolve-dra-manifest.sh index d5b442d82e04b..67d86dbe5abac 100755 --- a/.ci/scripts/resolve-dra-manifest.sh +++ b/.ci/scripts/resolve-dra-manifest.sh @@ -7,7 +7,7 @@ strip_version() { fetch_build() { >&2 echo "Checking for build id: https://artifacts-$1.elastic.co/$2/latest/$3.json" - curl -sS https://artifacts-$1.elastic.co/$2/latest/$3.json \ + curl -sSf https://artifacts-$1.elastic.co/$2/latest/$3.json \ | jq -r '.build_id' } @@ -16,18 +16,25 @@ BRANCH="${BRANCH:-$2}" ES_VERSION="${ES_VERSION:-$3}" WORKFLOW=${WORKFLOW:-$4} -LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $ES_VERSION) +if [[ "$WORKFLOW" == "staging" ]]; then + LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $ES_VERSION) +elif [[ "$WORKFLOW" == "snapshot" ]]; then + LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $BRANCH) +else + echo "Unknown workflow: $WORKFLOW" + exit 1 +fi -# Commented out because there's only one 7.17 branch now -# LATEST_VERSION=$(strip_version $LATEST_BUILD) +LATEST_VERSION=$(strip_version $LATEST_BUILD) -# # If the latest artifact version doesn't match what we expect, try the corresponding version branch. -# # This can happen when the version of artifact has been bumped on the master branch. -# if [ "$LATEST_VERSION" != "$ES_VERSION" ]; then -# echo "Latest build for '$ARTIFACT' is version $LATEST_VERSION but expected version $ES_VERSION." 1>&2 -# NEW_BRANCH=$(echo $ES_VERSION | sed -E "s/([0-9]+\.[0-9]+)\.[0-9]/\1/g") -# echo "Using branch $NEW_BRANCH instead of $BRANCH." 1>&2 -# LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $NEW_BRANCH) -# fi +# If the latest artifact version doesn't match what we expect, try the corresponding version branch. +# This can happen when the version of artifact has been bumped on the master branch. +if [ "$LATEST_VERSION" != "$ES_VERSION" ]; then + echo "Latest build for '$ARTIFACT' is version $LATEST_VERSION but expected version $ES_VERSION." 1>&2 + NEW_BRANCH=$(echo $ES_VERSION | sed -E "s/([0-9]+\.[0-9]+)\.[0-9]/\1/g") + + echo "Using branch $NEW_BRANCH instead of $BRANCH." 1>&2 + LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $NEW_BRANCH) +fi echo $LATEST_BUILD