Search code examples
gitlabcicd

global level tags for gitlab CI/CD


What I am trying to achieve:

In my gitlab-ci file, I would like each and every jobs to have this:

  tags:
    - type/docker
    - os/linux

What did I try:

I have hundreds of jobs in my file. As of right now, for each one of them, I am duplicating this:

some-first-job:
  stage: security
  tags:
    - type/docker
    - os/linux

some-second-job:
  image: 
  stage: security
  tags:
    - type/docker
    - os/linux

some-hundread-job:
  stage: security
  tags:
    - type/docker
    - os/linux

Question is there a way to set the tag globally, such as:

tags:
  - type/docker
  - os/linux

some-first-job:
  stage: security

some-second-job:
  image: 
  stage: security

some-hundread-job:
  stage: security

This tags is for the gitlab runner to pick it up.

Is there any way to "refactor the tags" so every job can benefit from it?

Or maybe there is a way to configure the gitlab runner globally?


Solution

  • You were very close to the solution, just put the tags under default: block like this:

    default:
      tags:
        - type/docker
        - os/linux
    

    more information is available on their documentation - https://docs.gitlab.com/ee/ci/yaml/#default