Skip to content

Backend: Using variables in rules:exists does not work if the variable contains a `/`

Summary

When using variables in the rules:exists keyword, the pipeline does not start if the variable contains /

Furthermore, if there is a . in the rules:exists configuration at all, it will never start. The same issue occurs when replacing . with $CI_PROJECT_DIR, and the output of pwd and echo $CI_PROJECT_DIR are an exact match, while an ls shows the folders are indeed present

Steps to reproduce

Create a repository containing a folder named folder and a file named flag inside it. Add a .gitlab-ci.yml with the following configuration

variables:
  dir: "folder"
  file: "flag"
  full_path: "folder/flag"

a:
  rules:
    - exists:
        - $dir/$file
  image: alpine:latest
  script:
    - echo hi

b:
  rules:
    - exists:
        - $full_path
  image: alpine:latest
  script:
    - echo hi

c:
  rules:
    - exists:
        - ./folder/flag
  image: alpine:latest
  script:
    - echo hi

What is the current bug behavior?

Only job a starts

What is the expected correct behavior?

All the jobs should start

Relevant links

Backend: Support variables in rules:exists (#283881 - closed) and Support variables in rules: exists (!101639 - merged)

Relevant code likely here.

Edited by Manuel Grabowski