Mahela Wickramasekara
Mahela Wickramasekara

Reputation: 733

Regular expression help to get the opposite in a gitlab CI pipeline

I have below regular expression that check whether we do not have --deploy in a commit message

deploy_review:
  <<: *deploy_review_base
  except:
    refs:
      - tags
      - master
    variables:
      - $CI_COMMIT_BRANCH != "review" && $CI_COMMIT_MESSAGE !~ /^.*--deploy/

Now I want to check the opposite of this, that is I want to check where this string --deploy is present in a commit message. Opposite of above expression. is there a way to achieve this ?

Appreciate any help on this

Thanks,

Upvotes: 0

Views: 1074

Answers (1)

sytech
sytech

Reputation: 40861

To invert the matching logic, just use =~ instead of !~.

Though your current logic (using !~) checks that the regex pattern does not match. =~ is used to check if the regex pattern does match. You should double check your regex pattern works as expected.

Upvotes: 3

Related Questions