Jenkins pipeline groovy.json.internal.LazyMap

错误原因是因为使用 `` 导致的。
具体根源解释为:

Since Groovy 2.3 (note: Jenkins 2.7.1 uses Groovy 2.4.7) JsonSlurper returns LazyMap instead of HashMap. This makes new implementation of JsonSlurper not thread safe and not serializable. This makes it unusable outside of @NonDSL functions in pipeline DSL scripts.

However you can fall-back to groovy.json.JsonSlurperClassic which supports old behavior and could be safely used within pipeline scripts.

解决方法使用 JsonSlurperClassic 代替 JsonSlurper ,示例:

@NonCPS
def jsonParse(def json) {
    new groovy.json.JsonSlurperClassic().parseText(json) // 重点
}

node('master') {
    def config =  jsonParse(readFile("config.json"))
    ...
}

(END)

你可能感兴趣的:(CICD)