State that step-level env variables override pipeline-level values#1129
Open
mokagio wants to merge 1 commit intobuildkite:mainfrom
Open
State that step-level env variables override pipeline-level values#1129mokagio wants to merge 1 commit intobuildkite:mainfrom
mokagio wants to merge 1 commit intobuildkite:mainfrom
Conversation
This pipeline:
```yml
env:
GLOBAL: global value we don't try to override
GLOBAL_OVERRIDE: if you read this, then the global value takes precendence
steps:
- label: "Test for env variables resolution"
command: |
echo "GLOBAL = $$GLOBAL"
echo "GLOBAL_OVERRIDE = $$GLOBAL_OVERRIDE"
echo "LOCAL = $$LOCAL"
env:
LOCAL: local value
GLOBAL_OVERRIDE: if you read this, then the global value was overridden by the local one
```
Results in this output:
```
GLOBAL = global value we don't try to override
GLOBAL_OVERRIDE = if you read this, then the global value was overridden by the local one
LOCAL = local value
```
That is, the value for `GLOBAL_OVERRIDE` set in the step `env` node takes precedence over the value set in the `env` node in the pipeline root.
This commit updates the note regarding the environment variables overriding behavior in the documentation to reflect that.
Contributor
|
Hey @mokagio I love the level of detail you've gone to on this PR. 🌟 I did a little digging and it turns out that it isn't quite as straightforward as this though, apparently the behavior changes depending on whether you're using a YAML pipeline or the older visual step editor. I'll work on making that clear in the docs. |
pull bot
pushed a commit
to Reality2byte/docs-1
that referenced
this pull request
Feb 23, 2026
Move agent lifecycle content to a new top-level page for the Agent docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the note regarding the environment variables overriding behavior in the documentation to reflect the behavior experienced in production.
Details
This pipeline:
Results in this output:
That is, the value for
GLOBAL_OVERRIDEset in the stepenvnode takes precedence over the value set in theenvnode in the pipeline root.You can verify the behavior in action here.
Rationale
I opened a PR directly, rather than going through an issue first, because the behavior I see in production is what I would expect from a hierarchical configuration system and I'm guessing the docs are either out of date or wrong.
It's possible my expectation is incorrect, in which case this PR should be closed and a fix should be issued in the way the agent (?) resolves the variables hierarchy.
Next Steps
I've checked the "Allow edits by maintainers" option, so you can take this over and reword my phrasing if needed.
Thanks! I love Buildkite ❤️