Usage of spec:include: within regular includes results in unexpected outcomes
spec:include: is specifically built for pipeline inputs.
We blocked usage for component inputs, but not for using it with regular inputs on included files. While this is not officially supported, some people are already getting value out of certain usage patterns. As seen in the original issue description below, there's also some unexpected outcomes that we should improve.
Original description:
Evidently 'local' has problem with branches or paths, because when I switch to 'project', the same file suddenly is found correctly.
If I include from a different repository in a non-default branch, and the inclusion chain reaches a path that exists in that branch but not in the default branch, GitLab says the path does not exist.
Related docs: https://docs.gitlab.com/ci/inputs/#define-pipeline-inputs-in-external-files
Reproducing
Branches:
- my-org/cicd@my-ref: has
jobs/comment-inputs.yml - my-org/cicd@main: does not have
jobs/comment-inputs.yml
Error:
Unable to run pipeline
jobs/comment.yml: Local filejobs/comment-inputs.ymldoes not exist!, unknown input arguments: foo
my-org/my-project
.gitlab-ci.yml
spec:
include:
- project: 'my-org/cicd'
ref: my-ref
file: '/jobs/comment-inputs.yml'
---
include:
- project: 'my-org/cicd'
ref: my-ref # important, as the file does not exist in 'main'
file:
- '/jobs/comment.yml'
inputs:
foo: $[[ inputs.foo ]]
my-org/cicd
jobs/comment-inputs.yml
inputs:
foo:
type: string
default: ""jobs/comment.yml
spec:
include:
- local: jobs/comment-inputs.ymlWorkaround
All works when I change 'local' to 'project':
jobs/comment.yml
spec:
include:
- project: my-org/cicd
ref: my-ref
file: jobs/comment-inputs.yml