title: Creating a Jenkins environment variable using Groovy
body: <p>My project takes in a version number (separated by '.' or '_'). I tried writing a Groovy script that creates a Jenkins environment variable using only the first two of these numbers:</p>
  <pre><code>//Get the version parameter
  def env = System.getenv()
  def version = env['currentversion']
  def m = version =~/\d{1,2}/
  env = ['miniVersion':m[0].m[1]]
  </code></pre>
  <p>Am I doing this correctly?  Can I even create a new environment variable? Is there a better solution to this?</p>