title: GitLab CI allow job run only when commit message differs from regex
body: <p>I'm using GitLab.com. I want to run a job when it's on the beta branch and the commit message doesn't start with: <code>chore(release)</code>. Here is my attempt:</p>
  <pre class="lang-yaml prettyprint-override"><code># --snip--
  
  release_beta:
    stage:  release
    image: 
      name: &lt;private_image&gt;
      entrypoint:
        - '/usr/bin/env'
        - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
    before_script:
      - cp $SR_CONFIG_PATH/.releaserc.json .
    script:
      - npx semantic-release
    rules:
      # so we don't trigger a release job when semantic-release pushes the release
      - if: '$CI_COMMIT_BRANCH == &quot;beta&quot; &amp;&amp; $CI_COMMIT_MESSAGE !~ /^chore(release)/'
  
  </code></pre>
  <p>This doesn't work and the job is always triggered on the <code>beta</code> branch. I tried with <code>=~</code> variation and it didn't work either. I can't seem to make the regex test work even though it's mentioned in the documentation: <a href="https://docs.gitlab.com/ee/ci/jobs/job_control.html#common-if-clauses-for-rules" rel="nofollow noreferrer">https://docs.gitlab.com/ee/ci/jobs/job_control.html#common-if-clauses-for-rules</a>.</p>
  <p><a href="https://i.stack.imgur.com/ONxuL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ONxuL.png" alt="screenshot from documentation" /></a></p>
  <p>The job failed because the user doesn't have the permissions for that image (that's the reason I want to prevent the job from running in the first place):</p>
  <p><a href="https://i.stack.imgur.com/4JJuK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4JJuK.png" alt="enter image description here" /></a></p>