I am trying to convert a .gitlab-ci.yml job from the deprecated only/except pattern to rules, specifically I want to run a job only if it's for a tag but not if that tag starts with config-.
Currently we use this, which at least works1.
build_image:
stage: build_image
only:
- tags
except:
- /^config-.*$/
I have tried the rules based approach as follows, but that runs for every tag, including config:
build_image:
stage: build_image
rules:
# only tags, except config
- if: $CI_COMMIT_TAG
when: on_success
- if: '$CI_COMMIT_TAG =~ /^config-.*$/'
when: never
- when: never
Additionally I tried to use negative lookahead regex - without success, since gitlab's ci linter screams jobs:build_image:rules:rule if invalid expression syntax.
build_image:
stage: build_image
rules:
# only tags, except config (using negative lookahead)
- if: '$CI_COMMIT_TAG =~ /^(?!config-).*$/'
when: on_success
- when: never
So how can I trigger a job only for tags excluding a pattern with the new rules based approach?
1: apart from not being able to be combined with other rules later on