chore(NA): exports target branch when using a merge queue system at buildkite env script (#170918)

This PR adds the ability for us to have an env var on buildkite to allow
us to understand what is the final end target when running inside a
merge queue environment. It will be useful to redirect a couple of
dependent scripts that will start running inside the merge queue
environment once we activate it again

---------

Co-authored-by: Jon <jon@budzenski.me>
This commit is contained in:
Tiago Costa 2023-11-10 00:16:29 +00:00 committed by GitHub
parent 5900dff07d
commit afd020c63d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,24 @@ export KIBANA_BASE_BRANCH="$KIBANA_PKG_BRANCH"
KIBANA_PKG_VERSION="$(jq -r .version "$KIBANA_DIR/package.json")"
export KIBANA_PKG_VERSION
# Detects and exports the final target branch when using a merge queue
if [[ "$BUILDKITE_BRANCH" == "gh-readonly-queue"* ]]; then
# removes gh-readonly-queue/
BKBRANCH_WITHOUT_GH_MQ_PREFIX="${BUILDKITE_BRANCH#gh-readonly-queue/}"
# extracts target mqueue branch
MERGE_QUEUE_TARGET_BRANCH=${BKBRANCH_WITHOUT_GH_MQ_PREFIX%/*}
else
MERGE_QUEUE_TARGET_BRANCH=""
fi
export MERGE_QUEUE_TARGET_BRANCH
# Exports BUILDKITE_BRANCH_MERGE_QUEUE which will use the value from MERGE_QUEUE_TARGET_BRANCH if defined otherwise
# will fallback to BUILDKITE_BRANCH.
BUILDKITE_BRANCH_MERGE_QUEUE="${MERGE_QUEUE_TARGET_BRANCH:-$BUILDKITE_BRANCH}"
export BUILDKITE_BRANCH_MERGE_QUEUE
BUILDKITE_AGENT_GCP_REGION=""
if [[ "$(curl -is metadata.google.internal || true)" ]]; then
# projects/1003139005402/zones/us-central1-a -> us-central1-a -> us-central1