Pre-filled variables do not work for external custom CI config file paths

Summary

Pre-filled variables do not show up on the run pipeline form when the project's CI configuration resides on a separate project.

Steps to reproduce

  1. Create project X
  2. In project X create a .gitlab-ci.yml
  3. In the above file, add pre-defined variables
  4. Try to run manual pipeline on project X
  5. Pre-filled variables are shown on UI
  6. Create project Y
  7. Use settings of project Y to point its CI config path to project X: X@.gitlab-ci.yml
  8. Try to run a manual pipeline on project Y
  9. Pre-filled variables are not shown on the UI

Example Project

https://gitlab.com/gitlab-gold/hchouraria/custom-ci-config-path-proj

What is the current bug behavior?

Pre-filled variables defined in custom CI config path outside of repository does not render in run pipeline form

What is the expected correct behavior?

Pre-filled variables defined in custom CI config path outside of repository render in run pipeline form

Relevant logs and/or screenshots

Issue appears to be with the implementation of the ci_config_for(sha) method. It returns nil when the path is outside of repository.

# p is the project where pipelines need to run
irb(main):007:0> p.ci_config_path
=> ".gitlab-ci.yml@neo/gradle-proj"
irb(main):008:0> p.ci_config_for("master")
=> nil
irb(main):009:0> p.ci_config_for("main")
=> nil
irb(main):010:0> p.ci_config_for("blah")
=> nil
irb(main):011:0> p.ci_config_for("85a2533964185560237c98c80857c1bac7267542")
=> nil

Output of checks

This bug happens on GitLab.com

Possible fixes

Call chain where this fails to resolve:

Edited by Harsh Chouraria