Define spec:inputs section in a separate yml and include it in shared yaml file

Problem to solve

I have a shared yml file (lets say shared.yml) in a project having
spec:
inputs:
value1:
value2:
with default value and this shared file is being called from main project, now I want to create a separate yml file with spec:inputs variables only and include it in my shared file so that I don’t have to define these common inputs in multiple shared files.

Steps to reproduce

I created a separate yml file with spec:inputs section with variables only but while including this file in shared file, its giving error
Given inputs not defined in the spec section of the included configuration file(shared.yml in our case)

Configuration

I have included below file in shared.yml file which was created separately for spec:inputs only and removed spec:inputs section from shared.yml as spec:inputs section is defined in inputs.yml now.
include:
- local: templates/functions/inputs.yml

Versions

Please select whether options apply, and add the version information.

  • [ x] Self-managed
  • GitLab.com SaaS
  • Dedicated
  • Self-hosted Runners

If I understood you correctly, then this should be no problem.

main-project/consumer-projects:


include:
  - project: 'my-group/my-project'
    file: '/templates/shared.yml'
    inputs:
       value1: 123
       value2: 456

This would be the regular project which include the shared.yml.

shared-project:

spec:
  inputs:
    value1:
    value2:
---

include:
  - project: 'my-group/my-templates'
    file: '/templates/shared_parent.yml'
    inputs:
       value1:  $[[ inputs.value1 ]]
       value2:  $[[ inputs.value2 ]]
       value3: 789
       

In this shared.yml we include a shared.yml (I called it shared_parent.yml) as well and put additional inputs to it.

shared_parent:

spec:
  inputs:
    value1:
    value2:
    value3:
---

my-job:
  script:
     - echo "$[[ inputs.value1 ]]"
     - echo "$[[ inputs.value2 ]]"
     - echo "$[[ inputs.value3 ]]"

I didn’t test it, but the setup you desire would kinda look like that.