Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap

后端 未结 12 790
长发绾君心
长发绾君心 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:45

    A slightly more generalized form of the answer from @mkobit which would allow decoding of arrays as well as maps would be:

    import groovy.json.JsonSlurper
    
    @NonCPS
    def parseJsonText(String json) {
      def object = new JsonSlurper().parseText(json)
      if(object instanceof groovy.json.internal.LazyMap) {
          return new HashMap<>(object)
      }
      return object
    }
    

    NOTE: Be aware that this will only convert the top level LazyMap object to a HashMap. Any nested LazyMap objects will still be there and continue to cause issues with Jenkins.

提交回复
热议问题