include:rules:exists acts differently than <job>:rules:exists
Summary
rules:exists acts differently when used in an include section vs job definition
- When used in a job definition, rules:exists checks for file existence in the GitLab project where the job is running.
- When used in an include, rules:exists checks for the file existence in the GitLab project where the yml file containing the 'include:rules:exists' clause.
My expectation is that both rules:exists would check for existence in the GitLab project where the pipeline is running.
Steps to reproduce
- Create repo one add the following:
- test.txt (just a file, content not important)
- Add gitlab-ci.yml
stages:
- test
job-from-local:
stage: test
script:
- echo "This job rule on file exists in pipeline repo from pipeline repo"
rules:
- exists:
- test.txt
include:
- project: "ruskel/test-rule-exists-two"
ref: main
file: "include_rule.yml"
- project: "ruskel/test-rule-exists-two"
ref: main
file: "job_rule.yml"
- Create repo two and add the following:
- test2.txt (just a file, content not important)
- create include_rule.yml
include:
- project: "ruskel/test-rule-exists-two"
ref: main
file: "test_task.yml"
rules:
- exists:
- test.txt
- project: "ruskel/test-rule-exists-two"
ref: main
file: "test2_task.yml"
rules:
- exists:
- test2.txt
- Create job_rule.yml
job-from-pipeline:
stage: test
script:
- echo "This job rule on file exists in pipeline repo"
rules:
- exists:
- test.txt
job-from-include:
stage: test
script:
- echo "This job rule on file exists in include file repo"
rules:
- exists:
- test2.txt
- Create test_task.yml
include-from-pipeline:
stage: test
script:
- echo "This include rule on file exists in pipeline repo"
- Create test2_task.yml
include-from-include:
stage: test
script:
- echo "This include rule on file exists in included repo"
- Run the pipeline from repo one
- See the output where include-from-include and job-from-pipeline are executed
Example Project
What is the current bug behavior?
the include:rules:exists uses the files in the repo where the yaml that defines the include resides but job:rules:exists uses the files in the repo where the pipeline is executed
What is the expected correct behavior?
I would like to see both execute the rules:exists against the repo where the pipeline is executed. The use case for this is a custom 'testing.yml' file in a library that developers can include. This single include decides what actual implementation yml files should be included based on the repo configuration (ie pom.xml indicates maven testing implementation is required).
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)
Implementation Table
| Group | Issue Link |
|---|---|
| documentation |
|
| backend | #386040 (closed) |