Skip to content

Implement reading inputs from various file sources in CI header specs

What does this MR do and why?

Implement local, remote and project/ref/file file includes for CI header specs

Add support for the include keyword in GitLab CI header specifications to read input definitions from local files. This enables sharing common input definitions across multiple configuration files.

Example usage:

---
spec:
  inputs:
    environment:
      default: production
  include:
    - local: '/ci/inputs.yml'
    - remote: 'http://gdk.test:3000/flightjs/ci-commit-ref-name/-/raw/test-external-file-inputs/ci/sample.yml'
    - project: 'flightjs/ci-commit-ref-name'
      file: 'ci/sample.yml'
      ref: 'test-external-file-inputs'
---

References

Read inputs from a file (#415636) • Rajendra Kadam • 18.6

Screenshots or screen recordings

NA

How to set up and validate locally

Use the below CI config along with inputs definition file -

spec:
  include:
    - local: 'ci/inputs.yml'
    - remote: 'http://gdk.test:3000/flightjs/ci-commit-ref-name/-/raw/test-external-file-inputs/ci/sample.yml'
    - project: 'flightjs/ci-commit-ref-name'
      ref: 'test-external-file-inputs'
      file: 'ci/sample.yml'
  inputs:
    job_prefix:
      description: "Prefix for job names (inline)"
      default: "inline"
    environment:
      default: "production"

---

$[[ inputs.job_prefix ]]-test:
  script:
    - echo "Environment:" $[[ inputs.environment ]]
    - echo "Job prefix:" $[[ inputs.job_prefix ]]
    - echo "App version:" $[[ inputs.app_version ]]
    - echo "Replicas:" $[[ inputs.replicas ]]
    - echo "Sample:" $[[ inputs.sample ]]

ci/inputs.yml -

inputs:
  environment:
    default: "staging"
    options: ["development", "staging", "production"]
  app_version:
    default: "1.0.0"
  replicas:
    type: number
    default: 3

ci/sample.yml -

inputs:
  sample:
    default: "sample"
    options: ["sample", "sample-2", "sample-3"]

The pipeline that you may run locally should pass and print the input values in the job log.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #415636

Edited by Rajendra Kadam

Merge request reports

Loading