Only activate env: "KEY="
for empty environment variable value, clearly document pattern behavior
#2839
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 tests and documents expected behavior, and fixes what I believe is a very surprising special case:
env: "KEY="
should only match an empty/undefined environment variable value. Previously, it would match any value since an empty regex search matches anything.Use case where this is important: monorepo with 50 images where environment variable
ONLY_MODULE=...
specifies which image(s) to build. An empty value should build everything.Overall, I'd rather change syntax or key to e.g.
env: "KEY~=^my-regex$"
orenvRegex: KEY=REGEX
, and fix the implementation ofenv:
to compare the value exactly. But that would it backwards-incompatible and would still require the special!
handling implemented for both string and regex comparison. Hence I went for a patch that only fixes the expectation forenv: "KEY="
.