Since rules
are being favored over only/except
I ran into a situation where I need to negate a regex match but fail to see how to do so in the documentation. I think I managed a work around with a negative look ahead in the regex but haven’t tested it yet. Does anyone know if there’s a nicer way of doing this?
Current stage:
some_stage:
only:
- on_this_branch
except:
variables:
- $CI_COMMIT_MESSAGE =~ /dont-run-this/
Negative lookahead:
some_stage:
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "on_this_branch" &&
$CI_COMMIT_MESSAGE =~ /^((?!dont-run-this).)*$/
Do either of these syntax work?
some_stage:
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "on_this_branch" &&
$CI_COMMIT_MESSAGE !~ /dont-run-this/
some_stage:
rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "on_this_branch" &&
not $CI_COMMIT_MESSAGE =~ /dont-run-this/