Skip to content

Commit 848f9ec

Browse files
[9.2] [CI] Optionally pass along BUILDKITE_PULL_REQUEST* variables to triggered pipelines (#239465) (#239855)
# Backport This will backport the following commits from `main` to `9.2`: - [[CI] Optionally pass along BUILDKITE_PULL_REQUEST* variables to triggered pipelines (#239465)](#239465) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Brad White","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-21T07:53:34Z","message":"[CI] Optionally pass along BUILDKITE_PULL_REQUEST* variables to triggered pipelines (#239465)\n\n## Summary\n\nCloses #239463\n- See issue for examples and context\n\n### Testing\nTriggered\nhttps://buildkite.com/elastic/kibana-pull-request/builds/352003 from\nhttps://buildkite.com/elastic/kibana-renovate-helper/builds/20306\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"59b29f55e7fa2f8a4deff1f8db4faac6524f12f6","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:all-open","ci:build-storybooks","v9.3.0"],"title":"[CI] Optionally pass along BUILDKITE_PULL_REQUEST* variables to triggered pipelines","number":239465,"url":"https://github.com/elastic/kibana/pull/239465","mergeCommit":{"message":"[CI] Optionally pass along BUILDKITE_PULL_REQUEST* variables to triggered pipelines (#239465)\n\n## Summary\n\nCloses #239463\n- See issue for examples and context\n\n### Testing\nTriggered\nhttps://buildkite.com/elastic/kibana-pull-request/builds/352003 from\nhttps://buildkite.com/elastic/kibana-renovate-helper/builds/20306\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"59b29f55e7fa2f8a4deff1f8db4faac6524f12f6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/239465","number":239465,"mergeCommit":{"message":"[CI] Optionally pass along BUILDKITE_PULL_REQUEST* variables to triggered pipelines (#239465)\n\n## Summary\n\nCloses #239463\n- See issue for examples and context\n\n### Testing\nTriggered\nhttps://buildkite.com/elastic/kibana-pull-request/builds/352003 from\nhttps://buildkite.com/elastic/kibana-renovate-helper/builds/20306\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"59b29f55e7fa2f8a4deff1f8db4faac6524f12f6"}}]}] BACKPORT--> Co-authored-by: Brad White <[email protected]>
1 parent d1f1b72 commit 848f9ec

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.buildkite/scripts/steps/renovate/trigger_pr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ for var in $(env | grep ^GITHUB_PR_ | cut -d= -f1); do
1111
GITHUB_ENV_VARS+=("$var=${!var}")
1212
done
1313

14-
ts-node .buildkite/scripts/steps/trigger_pipeline.ts kibana-pull-request "$BUILDKITE_BRANCH" "$BUILDKITE_COMMIT" "" "${GITHUB_ENV_VARS[*]}"
14+
ts-node .buildkite/scripts/steps/trigger_pipeline.ts kibana-pull-request "$BUILDKITE_BRANCH" "$BUILDKITE_COMMIT" "" "${GITHUB_ENV_VARS[*]}" "true"

.buildkite/scripts/steps/trigger_pipeline.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
import type { BuildkiteTriggerBuildParams } from '#pipeline-utils';
1011
import { BuildkiteClient } from '#pipeline-utils';
1112

1213
const pipelineSlug = process.argv[2];
@@ -15,10 +16,19 @@ const commit = process.argv[4] || 'HEAD';
1516
const kibanaBuildId = process.argv[5] || '';
1617
// key=value pairs in space separated string
1718
const extraEnvVariables = process.argv[6] || '';
19+
const includeBuildkitePrVars = process.argv[7] === 'true' || process.argv[7] === '1';
1820

1921
(async () => {
2022
try {
2123
const client = new BuildkiteClient();
24+
25+
const buildkitePrVars: Partial<BuildkiteTriggerBuildParams> = {};
26+
if (includeBuildkitePrVars) {
27+
buildkitePrVars.pull_request_id = process.env.BUILDKITE_PULL_REQUEST;
28+
buildkitePrVars.pull_request_base_branch = process.env.BUILDKITE_PULL_REQUEST_BASE_BRANCH;
29+
buildkitePrVars.pull_request_repository = process.env.BUILDKITE_PULL_REQUEST_REPO;
30+
}
31+
2232
const build = await client.triggerBuild(pipelineSlug, {
2333
commit,
2434
branch,
@@ -31,6 +41,7 @@ const extraEnvVariables = process.argv[6] || '';
3141
}, {}),
3242
},
3343
ignore_pipeline_branch_filters: true, // Required because of a Buildkite bug
44+
...buildkitePrVars,
3445
});
3546
console.log(`Triggered build: ${build.web_url}`);
3647
process.exit(0);

0 commit comments

Comments
 (0)