DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Randall
Randall

Posted on

GitLab CI Inheritance Sucks

Or at least, cross-repo inheritance.

I've worked at a couple of places now where GitLab CI templates are heavily used, included across repos, and inherited from.

I've found it confusing, inflexible, and an enemy of build reproducibility.

In a repo where this is done heavily, if I want to change something, I must figure out:

  1. Does my .gitlab-ci.yml actually contain this job at all? Or is it from a template somewhere else?
  2. Where the heck is it (or its parent) coming from? This repo includes templates from three other repos, and they include templates from other repos too. Where it at???
  3. How do I change the parent job without breaking any other pipelines that depend on it? Maybe I can just inherit from it and add a before_script? But what if the parent job gets updated with its own before_script later, and my overriding it breaks something?
  4. Will the person who owns the parent template's repo let me change it?

So after getting all of that out of the way, I make the change in the template repo. It breaks someone else's pipeline somewhere. But there wasn't even a commit to their repo. Their pipeline just suddenly just starts failing. What?? This totally breaks build reproducibility!

I've gotten to where I'd rather just have a bunch of duplicated GitLab CI code across repos.

Am I crazy, am I missing something, or do others feel the same?

Top comments (7)

Collapse
 
philippegranet profile image
Philippe GRANET • Edited on

Since version 13.9, there is !reference tags:
docs.gitlab.com/ee/ci/yaml/yaml_op...

Use the !reference custom YAML tag to select keyword configuration from other job sections and reuse it in the current section. Unlike YAML anchors, you can use !reference tags to reuse configuration from included configuration files as well.

Collapse
 
tnir profile image
T "@tnir" N

It looks like that link has been now dead after 2021-11. New URL would be
docs.gitlab.com/ee/ci/yaml/yaml_op...

Collapse
 
superfola profile image
Alexandre Plateau

I agree, GitLab CI is lacking something like tags for inherited steps/jobs, something like [from-parent:user/repo] maybe (even though that's not YAML, that's the idea)

Collapse
 
philippegranet profile image
Philippe GRANET • Edited on
Collapse
 
superfola profile image
Alexandre Plateau

Exactly like this! I had no idea this existed, thanks!

Collapse
 
scandinave profile image
Romain LE BARO

I totally agree. I prefer the way used bu DroneCI where every task are small dedicated script contain inside docker image.

This let you compose instead of inherite and you can target a specific image version for your job. So if someone update the master image, your build is not broken.

Collapse
 
tnir profile image
T "@tnir" N

While being one of the largest developer of GitLab in the world, totally I agree 😭

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.