0

Whenever I try to use Json Sluper it throws this error: groovy.json.JsonSlurperClassic. Any Ideas on how I can resolve this? From what I can tell based of the docs it looks roughly correct?

My Jenkinsfile roughly looks like this:

@Library('Internal Library')

import groovy.json.JsonSlurperClassic
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils

def complianceFlags = [
    enable: true     
]


def envDef = [buildImage: "Internal Build Image", compliance: complianceFlags]

env.SFDX_AUDIENCE_URL = "https://test.salesforce.com"
env.HTTP_PROXY="Proxy URL"

executePipeline(envDef) {
    stage('Init') {
        def slurper = new groovy.json.JsonSlurperClassic()
        // checkout scm
        // buildInit()
        // sh 'printenv'
        sh "sfdx version"
        sh "git remote -v"
        

      }
    
   }

Here is the image of the error enter image description here

I was also able to pull this from the pipeline log:

https://pastebin.com/wEtetJKN

scarecrow
  • 84
  • 13
  • Not sure why it says Shell Script and does it show any other error message at all ? Did you try a simple jsonSlurperClassic for testing like example here - http://docs.groovy-lang.org/2.4.7/html/gapi/groovy/json/JsonSlurperClassic.html – rootkonda Jan 27 '21 at 20:10
  • @rootkonda I was able to extra some more log details. Will add it in, but that example did not work for me. – scarecrow Jan 27 '21 at 20:19
  • Does this answer your question? [Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap](https://stackoverflow.com/questions/37864542/jenkins-pipeline-notserializableexception-groovy-json-internal-lazymap) – sumitani Jan 27 '21 at 21:23
  • Nope, @sumitani I was able to fix it by nulling out slurper after using it for parsing the json that was needed. IE slurper = null. The error that was thrown was happening when running shell – scarecrow Jan 27 '21 at 22:17

1 Answers1

0

Setting slurper = null after IE:

            def jsonSlurper = new JsonSlurperClassic()
            //other stuff here
            jsonSlurper = null

afterwards sh worked fine

scarecrow
  • 84
  • 13