-
Bug
-
Resolution: Not A Defect
-
Major
-
None
Json slurper not working after upgrading Jenkins 2.3x.
an exception which occurred:
in field groovy.lang.Reference.value
in object groovy.lang.Reference@15a2b7bc
in field se.curity.utils.PipelineUtils$_getIdsvrVersions_closure1.jsonSlurper
in object se.curity.utils.PipelineUtils$_getIdsvrVersions_closure1@2586e985
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7579f9a1
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7579f9a1
Caused: java.io.NotSerializableException: groovy.json.JsonSlurper
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:274)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1143)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1101)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:268)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
This is my code snippet:
def getIdsvrVersions() { def returnVersions = [] def jsonSlurper = new JsonSlurper() withCredentials([ usernamePassword(credentialsId: 'release-api-credentials', usernameVariable: 'CLIENT_ID', passwordVariable: 'CLIENT_SECRET') ]) { accessToken = sh(returnStdout: true, script: 'curl -f -s -S -d "grant_type=client_credentials&client_secret=${CLIENT_SECRET}&client_id=${CLIENT_ID}&scope=release_read" "XXXXXXXXXXXX" | jq -r ".access_token"').trim() def getVersions = jsonSlurper.parseText(sh(returnStdout: true, script: """curl -f -s -S -H "Authorization: Bearer ${accessToken}" 'XXXXXXXXXXXX'""")) returnVersions.add(getVersions) } return returnVersions.flatten() }