Nested variables aren't expanded in rules:exists

Summary

!101639 (merged) introduced the ability to use variables in rules:exist, however, nested variables are not expanded. This lack of expansion results in situations where a pipeline/job will not be created.

Reported by customer in Zendesk ticket(internal)

Steps to reproduce

  • Create a new project
  • Create a folder named deployment
  • Create a file named test.yml under the above folder
  • Create .gitlab-ci.yml with this content
stages:
    - build

variables:
    TEST_FOLDER: deployment
    TEST_FILE: test
    TEST_PATH: $TEST_FOLDER/$TEST_FILE.yml

test-job1:
    stage: build
    script:
        - echo $TEST_FOLDER
        - echo $TEST_FILE
        - echo $TEST_PATH
    rules:
        - exists:
            - $TEST_FOLDER/$TEST_FILE.yml

test-job2:
    stage: build
    script:
        - echo $TEST_FOLDER
        - echo $TEST_FILE
        - echo $TEST_PATH
    rules:
        - exists:
            - $TEST_PATH
  • Validate or run the pipeline
  • Observe that the first job is created, however, the second job is not

Proposal

Tentative proposal being discussed below - Add sort_and_expand_all to depends_on

Example Project

https://gitlab.com/gitlab-gold/jiocastillo/ci-testing/variable-expansion

What is the current bug behavior?

Nested variables aren't expanded when used in rules:exist

What is the expected correct behavior?

Nested variables should be expanded when used in rules:exist

Relevant logs and/or screenshots

If the first job is removed, validating or running the pipeline results in:

  • Pipeline will not run for the selected trigger. The rules configuration prevented any jobs from being added to the pipeline.
Edited Jul 26, 2024 by Mark Nuzzo
Assignee Loading
Time tracking Loading