Allow triggered child build to inherit PR-related env vars from parent build

We recently added a pre-build pipeline before our various pipelines that get run whenever a PR is opened via a GitHub webhook, which then triggers a handful of other pipelines.

However, in the child pipelines that are triggered by the pre-build pipeline, any steps that attempt to check if the build is a PR or not via Buildkite env vars fail because only the initial pre-build pipeline seems to set
BUILDKITE_PULL_REQUEST, BUILDKITE_PULL_REQUEST_BASE_BRANCH, BUILDKITE_PULL_REQUEST_REPO env vars. Iā€™ve tried overriding these in the child pipelines via the env attribute in the trigger step, however these env vars appear to be read-only and cannot be overridden.

Itā€™d be really handy if the trigger step allowed you to set any child builds to inherit these PR env vars, so the PR status of a build could get passed through to any subsequent pipelines.

Thanks for the post! This was originally by design, but now that I think more about about, I think itā€™s a bug.

Will try and get something shipped today!

@keithpitt has this feature been added? If so please post the documentation link, I couldnā€™t find it.

Thanks

Hi here @pranit-harekar! Sorry for the delay in posting the details of how to do this. We did roll out support for this.

If you pass the following environment variables through to the triggered build, it will be associated with the pull request:

Iā€™ve opened a pull request on our docs with the details:

Thank you very much!!

1 Like