DEV Community

rndmh3ro
rndmh3ro

Posted on • Originally published at zufallsheld.de on

TIL how to alter gitlab-ci include-directives

We have a set of common pipeline jobs that are shared among different projects in Gitlab. We include them like this:

include:
  - project: 'shared/gitlab/linting'
    ref: master
    file:
      - markdown.yml
      - ansible.yml

Enter fullscreen mode Exit fullscreen mode

When you do this, these included jobs get executed with the runner that is defined in the included job. We do want to use a specific project runner though. We normally achieve this by adding a tag to the jobs. But how do you add a tag to a job that you include? The Gitlab community forums provided the answer. You simply add a tag to the job. :)

ansible:
  tags:
    - docker

Enter fullscreen mode Exit fullscreen mode

This way the job “ansible” that is defined in the included gitlab-ci configuration gets the “docker” tag added.

You can of course not only add tags but other things there, too!

Top comments (0)