Dynamic .gitlab-ci.yml or "importing from central repository" - Analog to Jenkins Groovy

Hey all,

A feature that I’ve been looking forward to for a bit now is something similar to Jenkins Groovy, when there, we can actually import the VERSIONED pipeline definition from a central repository :

@Library(‘company-shared-libs@master’) _

Script {
deploy = “mysw”
registry1 = “true”
redis = “1”
extraSteps = [‘scripts/extra.groovy’]
}

This way, a central team can update the pipeline definition for 100+ projects in one go.

While reading about Git submodules support, I had hope that, since our CI scripts live in $REPOSITORY/ci/ ; we could do something like that.

But that still leaves me with a question mark on .gitlab-ci.yml. It’s usually a chicken-egg problem since the submodules or any code that I could run at all to update the pipeline definitions lives within the .gitlab-ci.yml itself. By the time its running, even if it updates itself, it already started running with the previous version.

I’m just writing here to see if there are more people with the same problem/ideas and if any of you actually managed to solve the problem. Maybe I’m looking it from the wrong perspective. Ideas?

Thanks!

Hello,

depends a little bit on what you want to achieve. What about putting any logic into e.g. shell scripts and provision a blessed docker build image?

A colleague of mine wrote a small variation with one git repository with gitlab-ci templates which changes a list of other repositories whenever the stable branch changes. This needs more permissions on the other hand your central library has super permissions anyway. This approach.has the additional benefit that changes are clearly recorded as commit.