From 88969612c2ac06bd60bb496dda22cffae13dae10 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 08:49:29 +0100 Subject: [PATCH] use centralized version qualifier (#6651) (#6658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use centralized version qualifier for elastic-agent DRA flow (cherry picked from commit 297af6daa4aba127d25d613ee5c238509271b706) Co-authored-by: Paolo ChilĂ  (cherry picked from commit 4d98382e27245727cf5929c2cd401656fcb81bfa) --- .../pipeline.elastic-agent-binary-dra.yml | 6 +++-- .buildkite/scripts/version_qualifier.sh | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 .buildkite/scripts/version_qualifier.sh diff --git a/.buildkite/pipeline.elastic-agent-binary-dra.yml b/.buildkite/pipeline.elastic-agent-binary-dra.yml index eab9734bb14..d6b640b2982 100644 --- a/.buildkite/pipeline.elastic-agent-binary-dra.yml +++ b/.buildkite/pipeline.elastic-agent-binary-dra.yml @@ -47,8 +47,9 @@ steps: if: build.branch =~ /^[0-9]+\.[0-9x]+\$/ || build.env("RUN_STAGING") == "true" || build.env('VERSION_QUALIFIER') != null steps: - label: ":package: Build Elastic-Agent Core staging" - commands: - - .buildkite/scripts/steps/build-agent-core.sh + commands: | + source .buildkite/scripts/version_qualifier.sh + .buildkite/scripts/steps/build-agent-core.sh key: "build-dra-staging" artifact_paths: - "build/distributions/**/*" @@ -62,6 +63,7 @@ steps: - label: ":hammer: DRA Publish Elastic-Agent Core staging" command: | + source .buildkite/scripts/version_qualifier.sh echo "+++ Restoring Artifacts" buildkite-agent artifact download "build/**/*" . echo "+++ Changing permissions for the release manager" diff --git a/.buildkite/scripts/version_qualifier.sh b/.buildkite/scripts/version_qualifier.sh new file mode 100755 index 00000000000..88d172dad58 --- /dev/null +++ b/.buildkite/scripts/version_qualifier.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# An opinionated approach to managing the Elastic Qualifier for the DRA in a Google Bucket +# instead of using a Buildkite env variable. + +if [[ -n "$VERSION_QUALIFIER" ]]; then + echo "~~~ VERSION_QUALIFIER externally set to [$VERSION_QUALIFIER]" + return 0 +fi + +# DRA_BRANCH can be used for manually testing packaging with PRs +# e.g. define `DRA_BRANCH="main"` under Options/Environment Variables in the Buildkite UI after clicking new Build +BRANCH="${DRA_BRANCH:="${BUILDKITE_BRANCH:=""}"}" + +qualifier="" +URL="https://storage.googleapis.com/dra-qualifier/${BRANCH}" +if curl -sf -o /dev/null "$URL" ; then + qualifier=$(curl -s "$URL") +fi + +export VERSION_QUALIFIER="$qualifier" +echo "~~~ VERSION_QUALIFIER set to [$VERSION_QUALIFIER]"