title: Update version following semver with groovy in Jenkinsfile
body: <p>I'm currently trying to automate the versioning of my maven project with a Jenkins (version 2.190.3) job and following the SemVer. So I have my Jenkinsfile and I'm doing something like that:</p>
  
  <pre><code>script {
     def version = "1.2.4"
     def pattern = ~/(\d{1,3})\.(\d{1,3})\.\d{1,4}$/
     def newVersion = version.replaceFirst(pattern) { _,major,minor -&gt; "${major}.${(minor as int) + 1}.0"}
  }
  </code></pre>
  
  <p>The expectation is to have 1.3.0 in <strong>newVersion</strong>.
  The code seems OK, working on web console but when I'm using Jenkins I have the following error: </p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Cannot execute null+1</p>
  </blockquote>
  
  <p>Am I doing something wrong ?</p>