Skip to content

Allow a list of files in CI include:file syntax

Release notes

Previously when adding multiple files using the include:file syntax you would have to specify the project and ref for each file. In this release, we've added support to accept a list of files, so now you can specify the project and the ref once and provide a list of files, this way you save you time so you wont not need to repeat yourself and will make the pipeline configuration less verbose.

include:
  - project: devops/ci-cd/pipelines
    ref: latest
    file: 
      - terraform/terraform.yml
      - terraform/deploy/continuous.yml
      - ...

Problem to solve

GitLab 11.7 introduced the include:file syntax for including a file from another project in CI configurations. It currently accepts a single file. In my GitLab instance, I have a GitLab project that holds a collection of CI configurations for all projects, and it is common for projects to include multiple files.

The include:file syntax only allows a single file to be included. It would be useful if it allowed multiple multiple files to be specified.

Target audience

Further details

Here is an example of two files being included from one common project and ref.

include:
  - project: devops/ci-cd/pipelines
    ref: latest
    file: terraform/terraform.yml
  - project: devops/ci-cd/pipelines
    ref: latest
    file: terraform/deploy/continuous.yml

Proposal

The include:file syntax should accept a list of files. That way, the project and ref don't have to be repeated, reducing the likelihood of errors and making changes easier.

include:
  - project: devops/ci-cd/pipelines
    ref: latest
    file: 
      - terraform/terraform.yml
      - terraform/deploy/continuous.yml

This requires refactoring of the files at: https://gitlab.com/gitlab-org/gitlab/-/tree/master/lib/gitlab/ci/config/external and we should count each file from the project: entry as a separate entry for max limit of includes(the example above should still consume 2 entries in the list form)

What does success look like, and how can we measure that?

When a GitLab project includes multiple CI files from a common source project and ref, the local .gitlab-ci.yml file should be DRY by not repeating the project and ref for every single file.

Links / references

include:file

gitlab-ce!24101

gitlab-ce!24098

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

Edited by 🤖 GitLab Bot 🤖