From 9d048c063ac1790188317aec744fe431a41ce051 Mon Sep 17 00:00:00 2001 From: Pavel Zorin Date: Fri, 19 Jul 2024 18:24:26 +0200 Subject: [PATCH] [Ci] Fix DRA artifacts permissions (#5175) * Debug DRA * Debug DRA * Debug DRA * [CI] Fix packaging permissions * [CI] Fix packaging permissions * CHanged added read permissions * CHanged added read permissions * Fix veriables interpolation * Debug * Debug * Debug * Debug * Cleanup * Cleanup (cherry picked from commit 0f4c2779efc49153046b2cac77e8ee5675ab1478) --- .buildkite/pipeline.elastic-agent-package.yml | 31 ++++++++++--------- .buildkite/scripts/common.sh | 5 ++- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.buildkite/pipeline.elastic-agent-package.yml b/.buildkite/pipeline.elastic-agent-package.yml index 25c538f25f9..a1fe16d696a 100644 --- a/.buildkite/pipeline.elastic-agent-package.yml +++ b/.buildkite/pipeline.elastic-agent-package.yml @@ -1,8 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json env: DOCKER_REGISTRY: "docker.elastic.co" - SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 - SETUP_MAGE_VERSION: '1.14.0' # this is required in order to allow the build process to override the default PWD of the BEAT_NAME. BEAT_NAME: "elastic-agent" # after moving elastic-agent out of beats, we should update the URL of the packaging. @@ -63,14 +61,14 @@ steps: machineType: "c2-standard-16" diskSizeGb: 400 command: | - if [[ -z "${MANIFEST_URL}" ]]; then + if [[ -z "$${MANIFEST_URL}" ]]; then export MANIFEST_URL=$(buildkite-agent meta-data get MANIFEST_URL --default "") - if [[ -z "${MANIFEST_URL}" ]]; then + if [[ -z "$${MANIFEST_URL}" ]]; then echo ":broken_heart: Missing MANIFEST_URL variable or empty string provided" exit 1 fi fi - if [[ -z "${MAGEFILE_VERBOSE}" ]]; then + if [[ -z "$${MAGEFILE_VERBOSE}" ]]; then export MAGEFILE_VERBOSE=$(buildkite-agent meta-data get MAGEFILE_VERBOSE --default "0") fi .buildkite/scripts/steps/package.sh @@ -86,17 +84,18 @@ steps: PLATFORMS: "linux/arm64" PACKAGES: "docker" command: | - if [[ -z "${MANIFEST_URL}" ]]; then + if [[ -z "$${MANIFEST_URL}" ]]; then export MANIFEST_URL=$(buildkite-agent meta-data get MANIFEST_URL --default "") - if [[ -z "${MANIFEST_URL}" ]]; then + if [[ -z "$${MANIFEST_URL}" ]]; then echo ":broken_heart: Missing MANIFEST_URL variable or empty string provided" exit 1 fi fi - if [[ -z "${MAGEFILE_VERBOSE}" ]]; then + if [[ -z "$${MAGEFILE_VERBOSE}" ]]; then export MAGEFILE_VERBOSE=$(buildkite-agent meta-data get MAGEFILE_VERBOSE --default "0") fi .buildkite/scripts/steps/package.sh + ls -lahR build/ artifact_paths: - "build/distributions/**/*" @@ -111,18 +110,22 @@ steps: DRA_PROJECT_ARTIFACT_ID: "agent-package" command: | echo "+++ Restoring Artifacts" - buildkite-agent artifact download "build/**/*" . - echo "+++ Changing permissions for the release manager" + buildkite-agent artifact download "build/**/*" . + + echo "+++ Changing permissions for the release manager" + sudo chmod -R a+r build/distributions/ sudo chown -R :1000 build/distributions/ + ls -lahR build/ + echo "+++ Running DRA publish step" - if [[ -z "${MAGEFILE_VERBOSE}" ]]; then + if [[ -z "$${MAGEFILE_VERBOSE}" ]]; then export MAGEFILE_VERBOSE=$(buildkite-agent meta-data get MAGEFILE_VERBOSE --default "0") fi - if [[ -z "${DRA_DRY_RUN}" ]]; then + if [[ -z "$${DRA_DRY_RUN}" ]]; then DRA_DRY_RUN=$(buildkite-agent meta-data get DRA_DRY_RUN --default "") export DRA_DRY_RUN fi - if [[ -z "${DRA_VERSION}" ]]; then + if [[ -z "$${DRA_VERSION}" ]]; then DRA_VERSION=$(buildkite-agent meta-data get DRA_VERSION --default "") export DRA_VERSION fi @@ -158,7 +161,7 @@ steps: .buildkite/scripts/steps/dra-publish.sh # Artifacts will be uploaded via the artifact_paths entry above echo "+++ Set job metadata if TRIGGER_JOB_ID is properly set" - if [[ -z "${TRIGGER_JOB_ID}" ]]; then + if [[ -z "$${TRIGGER_JOB_ID}" ]]; then echo "TRIGGER_JOB_ID is not set, so not setting metadata" else # If a pipeline that triggered this build passes in a "TRIGGER_JOB_ID" env var, that diff --git a/.buildkite/scripts/common.sh b/.buildkite/scripts/common.sh index 86c370ae360..43a18a2dbc1 100644 --- a/.buildkite/scripts/common.sh +++ b/.buildkite/scripts/common.sh @@ -6,12 +6,11 @@ if [[ -z "${WORKSPACE-""}" ]]; then WORKSPACE=$(git rev-parse --show-toplevel) export WORKSPACE fi -PIPELINE="${WORKSPACE}/.buildkite/pipeline.elastic-agent-package.yml" if [[ -z "${SETUP_MAGE_VERSION-""}" ]]; then - SETUP_MAGE_VERSION=$(grep -oe "SETUP_MAGE_VERSION\: [\"'].*[\"']" "$PIPELINE" | awk '{print $2}' | sed "s/'//g" ) + SETUP_MAGE_VERSION="1.14.0" fi if [[ -z "${SETUP_GVM_VERSION-""}" ]]; then - SETUP_GVM_VERSION=$(grep -oe "SETUP_GVM_VERSION\: [\"'].*[\"']" "$PIPELINE" | awk '{print $2}' | sed "s/'//g" ) + SETUP_GVM_VERSION="v0.5.0" # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 fi BEAT_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' "${WORKSPACE}/version/version.go") export BEAT_VERSION