Bibas
Bibas

Reputation: 538

Using Gitlab CI from a submodule

I'm trying to "mutualize" my CI.

I have a lot of project that use basically the same gitlab-ci.yml.

I was thinking about creating a git submodule containing the gitlab-ci.yml that all my project are using, in which I could inject env variable in order to make it generic so I could re-use it in my futur projects.

My problem is that I don't see any documentation about this so I was wondering :

Thanks !

Upvotes: 1

Views: 1998

Answers (1)

Val Berthe
Val Berthe

Reputation: 2054

What you're looking for are Gitlab CI template files, that can be include'd in other .gitlab-ci.yml files.

You can check out the documentation for include here.

Example :

# .gitlab.ci.yml

include:
  - 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
  - '/templates/.after-script-template.yml'

This includes CI files with default variables, stages, workflows that can be overriden anywhere in your other CI files. This brings the genericity you need.

Upvotes: 1

Related Questions