Variables set by an earlier AND-group member's variables: block are now injected into the evaluation context before testing later members' if: expressions. This matches GitLab CI behaviour where e.g. element 0 sets DEPLOY=true and element 1 can then check $DEPLOY without requiring the caller to inject that variable manually. Previously evalRuleGroup passed the same base vars closure to every member, so cascaded variables were never visible during if: evaluation (only in the merged output returned after the group fired). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.2 KiB
YAML
42 lines
1.2 KiB
YAML
---
|
|
# Tests that workflow.rules and job.rules accept the nested-array (AND-group)
|
|
# form where each outer entry can itself be a sequence of rule conditions.
|
|
workflow:
|
|
name: "${PIPELINE_NAME}"
|
|
auto_cancel:
|
|
on_new_commit: interruptible
|
|
rules:
|
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
|
variables:
|
|
PIPELINE_NAME: "main"
|
|
- - if: "$CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH =~ /^feat\\///"
|
|
variables:
|
|
PIPELINE_NAME: "feature"
|
|
- - if: "$CI_COMMIT_TAG"
|
|
- if: "$DEPLOY"
|
|
variables:
|
|
PIPELINE_NAME: "deploy"
|
|
|
|
# AND-group where element 0 sets PHASE=build; element 1 checks $PHASE (cascade).
|
|
# Without cascading, element 1 would never match because PHASE is not in
|
|
# pipeline variables. With cascading, element 1 sees PHASE from element 0.
|
|
- - if: "$CI_COMMIT_BRANCH"
|
|
variables:
|
|
PHASE: build
|
|
- if: "$PHASE"
|
|
variables:
|
|
PIPELINE_NAME: "branch-build"
|
|
|
|
variables:
|
|
DEPLOY: "false"
|
|
|
|
build:
|
|
stage: build
|
|
script: echo building
|
|
rules:
|
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
|
- - if: "$CI_PIPELINE_SOURCE == 'push'"
|
|
allow_failure: true
|
|
- if: "$DEPLOY"
|
|
when: manual
|