title: How to use groovy to populate an env variable in a declarative jenkins pipeline
body: <p>I am struggling to populate an environment variable in a Jenkinsfile using groovy</p>
  
  <p>The code below fails:</p>
  
  <pre><code>pipeline {
    environment {
      PACKAGE_NAME = JOB_NAME.tokenize('/')[1]
    }
  {
  </code></pre>
  
  <p>with the following error:</p>
  
  <blockquote>
    <p>Environment variable values can only be joined together with ‘+’s</p>
  </blockquote>
  
  <p>What am I doing wrong? Sorry if the question is basic, I am just starting with both groovy and pipelines.</p>