title: How can I use a regex with flags in a Jenkins pipeline when/changelog?
body: <p>I have a Jenkins pipeline stage that I want to skip if there isn't a magic string in the commit message of the form <code>Release: (major|minor|patch)</code> (case and some whitespace insensitive) not on the first line. I'm trying to use the <code>when</code> directive and <code>changelog</code> condition, but it doesn't seem to like my regex, either because it's malformed or literally interpreting the flags <code>.../im</code> or escaped whitespace <code>\s</code>. I don't quite know how to debug it efficiently...</p>
  
  <pre><code>stage('Publish') {
      when {
           changelog '/.*^release:\\s*(major|minor|patch)\\s*$/im'
      }
      # ...
  }
  </code></pre>
  
  <p>When it was a "bare" regex like <code>changelog /.*^</code>... it had a syntax error.</p>
  
  <p>Is there a way to get the regex to work, or would another solution like </p>
  
  <pre><code>when {
      expression { 
          ???? ==~ /.*^release:\\s*(major|minor|patch)\\s*$/im 
      }
  </code></pre>
  
  <p>be better? Not sure what can be dropped into ????.</p>