user3617723 user3617723 - 2 months ago 36
Groovy Question

Jenkins Workflow java.io.NotSerializableException: groovy.json.internal.LazyMap in Closure

I've got the following function in a workflow script that results in the error

java.io.NotSerializableException: groovy.json.internal.LazyMap


def getParentTagForCurrentBranch(appWorkspace) {

def parentTag = null

dir("${appWorkspace.getPath()}") {

parentTag = bat(script:"git describe --abbrev=0 --tags", returnStdout:true)
}

return parentTag
}


What I don't understand about the error is where I am using a LazyMap?

I've tried quite a few different variations of this block but all result in the error, I've also tried using the
@NonCPS
but that just results in the whole method being skipped.

Can anyone help me understand why this produces the error and how to resolve it?

Answer

Thanks the problem was with JsonSlurperswitching to JsonSlurperClassicdid the trick as mentioned here Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap

Comments