Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap

后端 未结 12 738
长发绾君心
长发绾君心 2020-11-27 03:08

Solved: Thanks to below answer from S.Richmond. I needed to unset all stored maps of the groovy.json.internal.LazyMap type whi

12条回答
  •  执念已碎
    2020-11-27 03:46

    This is the detailed answer that was asked for.

    The unset worked for me:

    String res = sh(script: "curl --header 'X-Vault-Token: ${token}' --request POST --data '${payload}' ${url}", returnStdout: true)
    def response = new JsonSlurper().parseText(res)
    String value1 = response.data.value1
    String value2 = response.data.value2
    
    // unset response because it's not serializable and Jenkins throws NotSerializableException.
    response = null
    

    I read the values from the parsed response and when I don't need the object anymore I unset it.

提交回复
热议问题