Documentation clarification: Environment-scoped variables with rules and include limitation
Summary
The current documentation at https://docs.gitlab.com/ci/environments/#limit-the-environment-scope-of-a-cicd-variable contains a warning added in !133283 (merged):
You should not use environment-scoped variables with
rulesorinclude. The variables might not be defined when GitLab validates the pipeline configuration at pipeline creation.
However, testing shows that environment-scoped variables work correctly with include. The limitation may be specific to using them with rules, or when using both rules and include together. The documentation needs clarification.
Background
Original MR: !133283 (merged) (merged October 5, 2023 in GitLab 16.5)
Testing Results
include
rules
rules AND include together
The current blanket warning may be preventing users from valid use cases with include.
Questions for Clarification
- Does the limitation apply to
rulesspecifically, or toincludeas well? - Is the issue only when using both
rulesANDincludetogether? - Has the behavior changed since GitLab 16.5 when this warning was added?
Proposed Documentation Updates
The documentation should be more specific about:
-
Which keyword(s) are actually problematic (
rules,include, or both together) -
What works (e.g., "environment-scoped variables work correctly with
include") - Why the limitation exists (pipeline validation timing, variable resolution order, etc.)