title: How to replace part of a declarative Jenkinsfile pipeline variable to get the name of the job?
body: <p>I want to get the name of the Jenkins job.  The name is a Jenkins environmental variable called JOB_NAME (and which looks like <code>project_name/branch</code>).  JOB_BASE_NAME strips off the <code>project_name/</code>, leaving <code>branch</code>.</p>
  
  <p>I want to get <code>project_name</code>.</p>
  
  <p>I thought there might be something like this I could do:</p>
  
  <pre><code>environment {
    NAME = "${env.JOB_NAME}.replaceAll(~/\/.*$/, '')
  }
  </code></pre>
  
  <p>and then use <code>${NAME}</code> later in the pipeline, but this doesn't seem to work</p>