title: Jenkins groovy regex match string : Error: java.io.NotSerializableException: java.util.regex.Matcher
body: <p>I'm trying to get the matched string from a regex in groovy. The matched string prints to the console  without problems, but when I try use the matched string in a git command I get the following error:</p>
  
  <pre><code>Err: Incremental Build failed with Error: java.io.NotSerializableException: java.util.regex.Matcher
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>                def binaryName = "298_application_V2_00_Build_07.hex"
  
                  def matches = (binaryName =~ /(V)(\d+)(_)(\d+)(_)(Build)(_)(\d+)/)
                  versionTag = ""+matches[0].getAt(0)                 
                  echo "${matches}"
                  echo "$versionTag"
                  bat("git tag $versionTag")
                  bat("git push origin --tags")
  </code></pre>
  
  <p>How can I get the matched string from the regex?</p>