title: Jenkins Workflow java.io.NotSerializableException: groovy.json.internal.LazyMap in Closure
body: <p>I've got the following function in a workflow script that results in the error  <code>java.io.NotSerializableException: groovy.json.internal.LazyMap</code></p>
  
  <pre><code>def getParentTagForCurrentBranch(appWorkspace) {
  
     def parentTag = null
  
     dir("${appWorkspace.getPath()}") {
  
        parentTag = bat(script:"git describe --abbrev=0 --tags", returnStdout:true)
     }
  
     return parentTag
  }
  </code></pre>
  
  <p>What I don't understand about the error is where I am using a LazyMap?</p>
  
  <p>I've tried quite a few different variations of this block but all result in the error, I've also tried using the <code>@NonCPS</code> but that just results in the whole method being skipped.</p>
  
  <p>Can anyone help me understand why this produces the error and how to resolve it?</p>