Skip to content

Commit 1b4a371

Browse files
authored
Use ES_VERSION to resolve manifest for ML and Beats (#130084) (#130097)
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 c057945) # Conflicts: # .ci/scripts/resolve-dra-manifest.sh
1 parent 6177830 commit 1b4a371

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

.ci/scripts/resolve-dra-manifest.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ strip_version() {
77

88
fetch_build() {
99
>&2 echo "Checking for build id: https://artifacts-$1.elastic.co/$2/latest/$3.json"
10-
curl -sS https://artifacts-$1.elastic.co/$2/latest/$3.json \
10+
curl -sSf https://artifacts-$1.elastic.co/$2/latest/$3.json \
1111
| jq -r '.build_id'
1212
}
1313

@@ -16,18 +16,25 @@ BRANCH="${BRANCH:-$2}"
1616
ES_VERSION="${ES_VERSION:-$3}"
1717
WORKFLOW=${WORKFLOW:-$4}
1818

19-
LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $ES_VERSION)
19+
if [[ "$WORKFLOW" == "staging" ]]; then
20+
LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $ES_VERSION)
21+
elif [[ "$WORKFLOW" == "snapshot" ]]; then
22+
LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $BRANCH)
23+
else
24+
echo "Unknown workflow: $WORKFLOW"
25+
exit 1
26+
fi
2027

21-
# Commented out because there's only one 7.17 branch now
22-
# LATEST_VERSION=$(strip_version $LATEST_BUILD)
28+
LATEST_VERSION=$(strip_version $LATEST_BUILD)
2329

24-
# # If the latest artifact version doesn't match what we expect, try the corresponding version branch.
25-
# # This can happen when the version of artifact has been bumped on the master branch.
26-
# if [ "$LATEST_VERSION" != "$ES_VERSION" ]; then
27-
# echo "Latest build for '$ARTIFACT' is version $LATEST_VERSION but expected version $ES_VERSION." 1>&2
28-
# NEW_BRANCH=$(echo $ES_VERSION | sed -E "s/([0-9]+\.[0-9]+)\.[0-9]/\1/g")
29-
# echo "Using branch $NEW_BRANCH instead of $BRANCH." 1>&2
30-
# LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $NEW_BRANCH)
31-
# fi
30+
# If the latest artifact version doesn't match what we expect, try the corresponding version branch.
31+
# This can happen when the version of artifact has been bumped on the master branch.
32+
if [ "$LATEST_VERSION" != "$ES_VERSION" ]; then
33+
echo "Latest build for '$ARTIFACT' is version $LATEST_VERSION but expected version $ES_VERSION." 1>&2
34+
NEW_BRANCH=$(echo $ES_VERSION | sed -E "s/([0-9]+\.[0-9]+)\.[0-9]/\1/g")
35+
36+
echo "Using branch $NEW_BRANCH instead of $BRANCH." 1>&2
37+
LATEST_BUILD=$(fetch_build $WORKFLOW $ARTIFACT $NEW_BRANCH)
38+
fi
3239

3340
echo $LATEST_BUILD

0 commit comments

Comments
 (0)