Sunday, October 9, 2022

[FIXED] How to compile multiple/different .gitlab-ci.yml file into a single .gitlab-ci.yml file located in a separate repository?

Issue

Is it possible to include multiple and different .gitlab-ci.yml file into a single file located in another subgroup/repository? If yes, then how can it be done?

What I want to do is to have a modular gitlab CI files which can be used by different subgrous and project repositories depending on what they need. I'm thinking on a scalability perspective, the reason why I thought of this is to avoid hard coding the ci file that will be used for a specific app/ source code and for them to pick a ci file that they will need.

Here's how I think it can be visualized: Gitlab Structure


Solution

You can include CI configuration files from other groups/projects irrespective of where your project lives in the hierarchy. You can do this using the include: directive.

# .gitlab-ci.yml in Repo D
include:
  - project: anygroup/anysubgroup/anyproject
    file: path/to/anyfile.yml

You can include many files from many different projects.

It is even possible to skip defining a .gitlab-ci.yml file in a particular project altogether by specifying a CI YAML file in another project in the project settings.



Answered By - sytech
Answer Checked By - Senaida (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.