Gitlab CI variable as a regex

Viewed 2186

I feel silly asking this question, but is it possible to do something like:

variables:
   TAG_EXP: /some regex/

Some job:
    only:
       - $TAG_EXP

The above won't work, but is there a way to achieve a similar goal?

My issue is the tag is used on a lot of jobs and I'd like to have the expression in one easy to change place.

1 Answers

Use extends.

For example:

stages:
  - build

.build:template:
  stage: build
  only:
    - my_tag

build:one:
  extends:
    - .build:template
  script:
    - echo "my first job"

build:two:
  extends:
    - .build:template
  script:
    - echo "my second job"

And both build jobs will inherit the stage and only tags.

Related