Multiple .gitlab-ci.yaml files per repository that run different pipelines

Hi all, I’m looking for a way to define multiple gitlab-ci config files (preferably in different sub-directories) and then using a variable in a trigger or via the api, select which gitlab-ci script I want to use when I trigger a pipeline. One idea I had is to use a variable in the path of an “include” local definition to allow the variable to specify the path of a different included file.

Basically, I’m looking for a way to trigger multiple completely different pipelines from the same repository based on some input. I’m looking to do this because I have a repo with a non-fixed number of “micro-codebases” in them and I want to run a different pipeline depending on the directory (micro-codebase) that I’m interested in. For a concrete example, I have a mono-repo and I don’t want to run the build/tests/linting on every single “micro-codebase” in that repo on every build.

Is this possible in Gitlab? If not, are there any “creative” ways to achieve this?

I think this is possible with generated includes. Basically, you can create an artifact file that is your “child” gitlab CI config file. Then you can reference the artifact in your trigger.

More information here

Just use different branches, I use orphan branches

I haven’t done it myself, but I found a relevant article

Many people use mono-repos nowadays, multiple products/libraries coming from a single repository that’s how I found the article.

1 Like

Think this is the right approach to do it:

child–parent-pipelines

the root .gitlab-ci.yml defines a parent pipeline that is a simple trigger of child pipelines that are defined in the repo sub-folders ex. a/.gitlab-ci.yml, b/.gitlab-ci.yml, c/.gitlab-ci.yml.

3 Likes