Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitlab rule if commit message doesn't contain WIP

I need to only run a pipe when the commit message does not contain WIP and the branch is a feature branch.. but whichever what i do it, it either doesn't run or like below always runs

I'm going around in circles; this is my last effort which seems to make sense to me but gets trigger no matter what the commit message says :/

stages:
  - stage
  - sprint
# -------------------------------------------------------------------

sprint:
  stage: sprint
  allow_failure: false
  image: node:lts
  script:
    - echo 'stuff'
  rules:
    - if: '$CI_COMMIT_BRANCH=~ /^feature(.?)*/ && $CI_COMMIT_MESSAGE  != /^WIP(.?)*/'
      when: always

1 Answers

You are using != operator instead of !~ to match a regular expression, so right now it takes you CI_COMMIT_MESSAGE regex literally.

see https://docs.gitlab.com/ee/ci/yaml/#common-if-clauses-for-rules for details.

like image 109
Andrew Avatar answered Jun 22 '26 02:06

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!