Parsing JSON on Jenkins Pipeline (groovy)
I finally find a BETTER solution!
readJSON() method from the Jenkins "Pipeline Utility Steps" plugin as shown here:
Here is a sample where we can finally ditch that ugly GROOVY JSONPARSE crap.
node() { stage("checkout") { def jsonString = '{"name":"katone","age":5}' def jsonObj = readJSON text: jsonString assert jsonObj['name'] == 'katone' // this is a comparison. It returns true sh "echo ${jsonObj.name}" // prints out katone sh "echo ${jsonObj.age}" // prints out 5 }}