Skip to content

Commit a90e86b

Browse files
authored
[9.0] [CI] Fallback to GITHUB_PR_NUMBER, when BUILDKITE_PULL_REQUEST is false (#237034) (#237162)
# Backport This will backport the following commits from `main` to `9.0`: - [[CI] Fallback to GITHUB_PR_NUMBER, when BUILDKITE_PULL_REQUEST is false (#237034)](#237034) <!--- Backport version: 10.0.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Brad White","email":"Ikuni17@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-10-01T16:22:05Z","message":"[CI] Fallback to GITHUB_PR_NUMBER, when BUILDKITE_PULL_REQUEST is false (#237034)\n\n## Summary\n\nBK has a bug where `BUILDKITE_PULL_REQUEST` is `false` when there should\nbe a PR number. Example\n[here](https://buildkite.com/elastic/kibana-pull-request/builds/345435).\nWe then deploy to `kibana-pr-false`. This has been happening for about\ntwo months from what I can tell and would have multiple PRs deploying to\nthe same URL and overwriting each other.","sha":"0870546e115330616410847bf3766588c4e68a50","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:all-open","ci:cloud-deploy","ci:project-deploy-elasticsearch","v9.2.0"],"title":"[CI] Fallback to GITHUB_PR_NUMBER, when BUILDKITE_PULL_REQUEST is false","number":237034,"url":"https://github.com/elastic/kibana/pull/237034","mergeCommit":{"message":"[CI] Fallback to GITHUB_PR_NUMBER, when BUILDKITE_PULL_REQUEST is false (#237034)\n\n## Summary\n\nBK has a bug where `BUILDKITE_PULL_REQUEST` is `false` when there should\nbe a PR number. Example\n[here](https://buildkite.com/elastic/kibana-pull-request/builds/345435).\nWe then deploy to `kibana-pr-false`. This has been happening for about\ntwo months from what I can tell and would have multiple PRs deploying to\nthe same URL and overwriting each other.","sha":"0870546e115330616410847bf3766588c4e68a50"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/237034","number":237034,"mergeCommit":{"message":"[CI] Fallback to GITHUB_PR_NUMBER, when BUILDKITE_PULL_REQUEST is false (#237034)\n\n## Summary\n\nBK has a bug where `BUILDKITE_PULL_REQUEST` is `false` when there should\nbe a PR number. Example\n[here](https://buildkite.com/elastic/kibana-pull-request/builds/345435).\nWe then deploy to `kibana-pr-false`. This has been happening for about\ntwo months from what I can tell and would have multiple PRs deploying to\nthe same URL and overwriting each other.","sha":"0870546e115330616410847bf3766588c4e68a50"}}]}] BACKPORT-->
1 parent 67a4885 commit a90e86b

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

.buildkite/scripts/steps/cloud/build_and_deploy.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ ELASTICSEARCH_SHA=$(curl -s $ELASTICSEARCH_MANIFEST_URL | jq -r '.sha')
2222
ELASTICSEARCH_CLOUD_IMAGE="docker.elastic.co/kibana-ci/elasticsearch-cloud-ess:$VERSION-$ELASTICSEARCH_SHA"
2323

2424
KIBANA_CLOUD_IMAGE="docker.elastic.co/kibana-ci/kibana-cloud:$VERSION-$GIT_COMMIT"
25-
CLOUD_DEPLOYMENT_NAME="kibana-pr-$BUILDKITE_PULL_REQUEST"
25+
26+
if [[ "${BUILDKITE_PULL_REQUEST:-false}" == "false" ]]; then
27+
PR_NUMBER="$GITHUB_PR_NUMBER"
28+
else
29+
PR_NUMBER="$BUILDKITE_PULL_REQUEST"
30+
fi
31+
32+
CLOUD_DEPLOYMENT_NAME="kibana-pr-$PR_NUMBER"
2633

2734
set +e
2835
DISTRIBUTION_EXISTS=$(docker manifest inspect $KIBANA_CLOUD_IMAGE &> /dev/null; echo $?)

.buildkite/scripts/steps/serverless/deploy.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ set -euo pipefail
55

66
source .buildkite/scripts/common/util.sh
77

8-
KIBANA_IMAGE="docker.elastic.co/kibana-ci/kibana-serverless:pr-$BUILDKITE_PULL_REQUEST-${BUILDKITE_COMMIT:0:12}"
8+
if [[ "${BUILDKITE_PULL_REQUEST:-false}" == "false" ]]; then
9+
PR_NUMBER="$GITHUB_PR_NUMBER"
10+
else
11+
PR_NUMBER="$BUILDKITE_PULL_REQUEST"
12+
fi
13+
14+
KIBANA_IMAGE="docker.elastic.co/kibana-ci/kibana-serverless:pr-$PR_NUMBER-${BUILDKITE_COMMIT:0:12}"
915

1016
deploy() {
1117
PROJECT_TYPE=$1
@@ -21,7 +27,7 @@ deploy() {
2127
;;
2228
esac
2329

24-
PROJECT_NAME="kibana-pr-$BUILDKITE_PULL_REQUEST-$PROJECT_TYPE"
30+
PROJECT_NAME="kibana-pr-$PR_NUMBER-$PROJECT_TYPE"
2531
VAULT_KEY_NAME="$PROJECT_NAME"
2632
is_pr_with_label "ci:project-persist-deployment" && PROJECT_NAME="keep_$PROJECT_NAME"
2733
PROJECT_CREATE_CONFIGURATION='{
@@ -143,16 +149,16 @@ $KIBANA_IMAGE
143149
144150
### Kibana pull request
145151
146-
$BUILDKITE_PULL_REQUEST
152+
$PR_NUMBER
147153
148154
### Further details
149155
150-
Caused by the GitHub label 'ci:project-deploy-observability' in https://github.com/elastic/kibana/pull/$BUILDKITE_PULL_REQUEST
156+
Caused by the GitHub label 'ci:project-deploy-observability' in https://github.com/elastic/kibana/pull/$PR_NUMBER
151157
EOF
152158

153159
GH_TOKEN="$GITHUB_TOKEN" \
154160
gh issue create \
155-
--title "[Deploy Serverless Kibana] for user $GITHUB_PR_TRIGGER_USER with PR kibana@pr-$BUILDKITE_PULL_REQUEST" \
161+
--title "[Deploy Serverless Kibana] for user $GITHUB_PR_TRIGGER_USER with PR kibana@pr-$PR_NUMBER" \
156162
--body-file "${GITHUB_ISSUE}" \
157163
--label 'deploy-custom-kibana-serverless' \
158164
--repo 'elastic/observability-test-environments'

0 commit comments

Comments
 (0)