buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Pass environment variables from parent build #304

Closed nullobject closed 5 years ago

nullobject commented 6 years ago

When I trigger another pipeline from a build, it would be nice if some of the environment vars from the parent build were automatically provided to the child build.

For example:

Currently I am manually mapping these environment vars manually every time I trigger my "docker-deploy" build pipeline:

  - label: ":rocket: Staging"
    trigger: docker-deploy
    branches: master
    build:
      message: "Deploy $BUILDKITE_PIPELINE_SLUG to staging"
      env:
        BUILDKITE_PARENT_BUILD_ID: "$BUILDKITE_BUILD_ID"
        BUILDKITE_PARENT_BUILD_NUMBER: "$BUILDKITE_BUILD_NUMBER"
        BUILDKITE_PARENT_BUILD_URL: "$BUILDKITE_BUILD_URL"
        BUILDKITE_PARENT_PIPELINE_SLUG: "$BUILDKITE_PIPELINE_SLUG"
keithpitt commented 5 years ago

@nullobject 👋 blast from the past!

I just wanted to give you a heads up that I shipped this! 🚀

BUILDKITE_TRIGGERED_FROM_BUILD_ID="da52eca0-a2a6-433c-8109-068a8f4b6e97"
BUILDKITE_TRIGGERED_FROM_BUILD_NUMBER="38"
BUILDKITE_TRIGGERED_FROM_BUILD_PIPELINE_SLUG="parent-pipeline-slug"

These are now available in builds created from other pipelines (not URL I'm afraid) but you should be able to reconstruct it using the new variables.

nullobject commented 5 years ago

@keithpitt Ooh, very nice 👍