include:rules:exists acts differently than <job>:rules:exists
<!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "type::bug" label: - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary <!-- Summarize the bug encountered concisely. --> 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 ```yaml 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 ```yaml 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 ```yaml 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 ```yaml include-from-pipeline: stage: test script: - echo "This include rule on file exists in pipeline repo" ``` - Create test2_task.yml ```yaml 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 - https://gitlab.com/ruskel/test-rule-exists-one - https://gitlab.com/ruskel/test-rule-exists-two ### What is the current *bug* behavior? <!-- Describe what actually happens. --> 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? <!-- Describe what you should see instead. --> 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 [Pipeline-jobs](/uploads/8dca253fb3accb1c2fdc196b6f31022b/Pipeline-jobs.png) <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise. --> ### Output of checks <!-- If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com --> #### Results of GitLab environment info <!-- Input any relevant GitLab environment information if needed. --> <details> <summary>Expand for output related to GitLab environment info</summary> <pre> (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`) </pre> </details> #### Results of GitLab application Check <!-- Input any relevant GitLab application check information if needed. --> <details> <summary>Expand for output related to the GitLab application check</summary> <pre> (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) </pre> </details> ## Implementation Table <!-- _NOTE: If the issue is not part of an epic, the implementation table can be removed. If it is part of an epic, make sure that the implementation table below mirrors the corresponding epic's implementation table content._ --> | Group | Issue Link | | ------ | ------ | | ~documentation | :point_left: You are here | | ~backend | https://gitlab.com/gitlab-org/gitlab/-/issues/386040 | ### Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem. -->
issue