Search code examples
yamlgitlab-cipipeline

Is there a way to make gitlab-ci pipeline not duplicate and easy to maintain?


I have several projects that have the same makefile targets; let's say : make init, make compile, make report.

for each repo project, I then have a quite complex pipeline script that defines several jobs (pseudo code here)

stage: one
  script:
   make init + make compile

stage: two
  script:
    make init + make report

stage: three
  script:
     make init TEST=true
...

The fact is that yaml script is the same and will be the same for all my projects, but it's quite painfull to maintain (for each new feature I have to update all repos)...

I would like to maintain/modify only one file.

Is there a simple solution to this?


Solution

  • You can always use the include tag to reuse code in gitlab-ci

    https://docs.gitlab.com/ee/ci/yaml/includes.html

    As a good example, I like the GitLab code pipeline itself

    https://gitlab.com/gitlab-org/gitlab/-/blob/master/.gitlab-ci.yml