title: Regex based rules clause does not work in GitLab CI
body: <p>I want my Gitlab CI job to <strong>not</strong> run when the commit message starts with a particular string: <code>[maven-scm]</code></p>
  <p>So, I have the below configuration in my <em>.gitlab-ci.yaml</em> file:</p>
  <pre class="lang-yaml prettyprint-override"><code>image: maven:3.6.3-jdk-11-slim
  
  stages:
    - test
  
  test:
    stage: test
    cache:
      key: all
      paths:
        - ./.m2/repository
    script:
      - mvn clean checkstyle:check test spotbugs:check
    rules:
      - if: '$CI_COMMIT_MESSAGE !~ /^\[maven-scm\] .*$/'
  </code></pre>
  <p>My commit message is: <code>[maven-scm] I hope the test job does not run</code></p>
  <p>But the test job still runs to my frustration. I went over the GitLab documentation for <a href="https://docs.gitlab.com/ee/ci/yaml/#rulesif" rel="nofollow noreferrer">rules</a> but could not find the reason why the job still runs. I am not sure if I am missing something.</p>
  <p>Would be great if someone can point me in the right direction.</p>
  <p><strong>Update:</strong></p>
  <p>I tried the only/except clause instead of the rules. I modified the yaml file to below:</p>
  <pre class="lang-yaml prettyprint-override"><code>image: maven:3.6.3-jdk-11-slim
  
  stages:
    - test
  
  test:
    stage: test
    cache:
      key: all
      paths:
        - ./.m2/repository
    script:
      - mvn clean checkstyle:check test spotbugs:check
    except:
      variables:
        - $CI_COMMIT_MESSAGE =~ /^\[maven-scm\] .*$/
  </code></pre>
  <p>The job still runs when the commit message starts with <code>[maven-scm]</code>.</p>