From 0622a662e68056fe6f278c88b85ca7660c422327 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:22:21 +0000 Subject: [PATCH] Support VERSION_QUALIFIER for elastic-agent-core DRA (#6551) (#6553) This commit adds support for the optional VERSION_QUALIFIER for the elastic-agent-core staging DRA builds. Closes #6543 (cherry picked from commit 7d1aaae2f21921d1ce9b36607ffae627031d1990) Co-authored-by: Dimitrios Liappis --- .buildkite/pipeline.elastic-agent-binary-dra.yml | 5 +++-- .buildkite/scripts/steps/build-agent-core.sh | 6 ++++++ .buildkite/scripts/steps/dra-publish.sh | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.buildkite/pipeline.elastic-agent-binary-dra.yml b/.buildkite/pipeline.elastic-agent-binary-dra.yml index 8ee2281762e..eab9734bb14 100644 --- a/.buildkite/pipeline.elastic-agent-binary-dra.yml +++ b/.buildkite/pipeline.elastic-agent-binary-dra.yml @@ -10,7 +10,8 @@ env: steps: - group: ":beats: DRA Elastic-Agent Core Snapshot :beats:" key: "dra-core-snapshot" - if: build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9x]+\$/ || build.env("RUN_SNAPSHOT") == "true" + # don't run snapshot builds with prereleases (non empty VERSION_QUALIFIER) unless forced (RUN_SNAPSHOT=true) + if: build.env("RUN_SNAPSHOT") == "true" || (build.env('VERSION_QUALIFIER') == null && (build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9x]+\$/)) steps: - label: ":package: Build Elastic-Agent Core Snapshot" commands: @@ -43,7 +44,7 @@ steps: - group: ":beats: DRA Elastic-Agent Core Staging :beats:" key: "dra-core-staging" - if: build.branch =~ /^[0-9]+\.[0-9x]+\$/ || build.env("RUN_STAGING") == "true" + 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: diff --git a/.buildkite/scripts/steps/build-agent-core.sh b/.buildkite/scripts/steps/build-agent-core.sh index b9300880964..deab9e0c851 100755 --- a/.buildkite/scripts/steps/build-agent-core.sh +++ b/.buildkite/scripts/steps/build-agent-core.sh @@ -6,12 +6,18 @@ source .buildkite/scripts/common.sh echo "+++ Build Agent artifacts" SNAPSHOT="" +VERSION_QUALIFIER="${VERSION_QUALIFIER:=""}" BEAT_VERSION_FULL=$BEAT_VERSION + if [ "$DRA_WORKFLOW" == "snapshot" ]; then SNAPSHOT="true" BEAT_VERSION_FULL="${BEAT_VERSION}-SNAPSHOT" fi +if [[ "$DRA_WORKFLOW" == "staging" ]] && [[ -n "$VERSION_QUALIFIER" ]]; then + BEAT_VERSION_FULL="${BEAT_VERSION_FULL}-${VERSION_QUALIFIER}" +fi + SNAPSHOT=$SNAPSHOT mage packageAgentCore chmod -R 777 build/distributions diff --git a/.buildkite/scripts/steps/dra-publish.sh b/.buildkite/scripts/steps/dra-publish.sh index bda5dd5eabd..c6af433993e 100755 --- a/.buildkite/scripts/steps/dra-publish.sh +++ b/.buildkite/scripts/steps/dra-publish.sh @@ -7,6 +7,7 @@ WORKFLOW="${DRA_WORKFLOW:=""}" COMMIT="${DRA_COMMIT:="${BUILDKITE_COMMIT:=""}"}" BRANCH="${DRA_BRANCH:="${BUILDKITE_BRANCH:=""}"}" PACKAGE_VERSION="${DRA_VERSION:="${BEAT_VERSION:=""}"}" +VERSION_QUALIFIER="${VERSION_QUALIFIER:=""}" # force main branch on PR's or it won't execute # because the PR branch does not have a project folder in release-manager @@ -50,7 +51,8 @@ function run_release_manager_list() { --commit "${_commit}" \ --workflow "${_workflow}" \ --version "${_version}" \ - --artifact-set "${_artifact_set}" + --artifact-set "${_artifact_set}" \ + --qualifier "${VERSION_QUALIFIER}" } # Publish DRA artifacts @@ -71,10 +73,11 @@ function run_release_manager_collect() { --workflow "${_workflow}" \ --version "${_version}" \ --artifact-set "${_artifact_set}" \ + --qualifier "${VERSION_QUALIFIER}" ${_dry_run} } -echo "+++ Release Manager ${WORKFLOW} / ${BRANCH} / ${COMMIT}"; +echo "+++ Release Manager Workflow: ${WORKFLOW} / Branch: ${BRANCH} / VERSION_QUALIFIER: ${VERSION_QUALIFIER} / Commit: ${COMMIT}" run_release_manager_list "${DRA_PROJECT_ID}" "${DRA_PROJECT_ARTIFACT_ID}" "${WORKFLOW}" "${COMMIT}" "${BRANCH}" "${PACKAGE_VERSION}" run_release_manager_collect "${DRA_PROJECT_ID}" "${DRA_PROJECT_ARTIFACT_ID}" "${WORKFLOW}" "${COMMIT}" "${BRANCH}" "${PACKAGE_VERSION}" "${DRY_RUN}" RM_EXIT_CODE=$?