Skip to content

Allow to recursively expand includes

Kamil Trzciński requested to merge allow-to-recursively-include into master

What does this MR do?

This extends include: to allow nested includes. Making the configuration truly Composable and hierarchical. The depth of includes is limited to 3.

This is nested-aware thus, based on type of include it properly resolves all relatives to the includes:

  1. local: preserves context of the current include, project and sha,
  2. remote: drops context, thus only publiclly available files can be included,
  3. project: changes project and sha context to be the one of the include,
  4. template: preserves only user.

Example

1. Project's gitlab-ci.yml

include:
  - template: Auto-DevOps.yaml
  - project: my-group/my-project
    file: my-generic-yaml.yaml
    ref: master

2. Auto-DevOps.yaml

include:
  - template: SAST.yaml
  - template: DAST.yaml
  - template: DockerBuild.yaml
  - template: ReviewApps.yaml
  - template: Staging.yaml
  - template: Production.yaml

3. my-group/my-project/my-generic-yaml.yml

include:
  - local: my-another-yaml.yml

This will use my-another-yaml.yml relative to my-group/my-project using the ref: master.

4. my-group/my-project/my-another-yaml.yml

include:
  - template: Pages-Hugo.yaml

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56836

Resolves https://gitlab.com/gitlab-org/gitlab-ce/issues/55937#note_143126814

Does this MR meet the acceptance criteria?

Edited by Grzegorz Bizon

Merge request reports