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
- Create project X
- In project X create a .gitlab-ci.yml
- In the above file, add pre-defined variables
- Try to run manual pipeline on project X
- Pre-filled variables are shown on UI
- Create project Y
- Use settings of project Y to point its CI config path to project X:
X@.gitlab-ci.yml
- Try to run a manual pipeline on project Y
- 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:
- https://gitlab.com/gitlab-org/gitlab/blob/7a1b3d9f7491a97160e053b4a96c62cb59d09a10/app/services/ci/list_config_variables_service.rb#L25
- https://gitlab.com/gitlab-org/gitlab/blob/aeff2cf9f841076ee6a1e2bb3d45a1689e38205a/app/models/project.rb#L2586-2588
- https://gitlab.com/gitlab-org/gitlab/blob/f16420e7e65c95032690584a73b5540a2f1885bd/app/models/repository.rb#L1042-1044
Edited by Harsh Chouraria