Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-59920

JsonSlurper errors within Jenkins Pipeline

    Details

    • Similar Issues:

      Description

      I am trying to use jsonslurper class within my Jenkinsfile and pipeline and it throws the below error.
      Caused: java.io.NotSerializableException: groovy.json.internal.LazyMap
       

      My jenkins file given below.

      #!groovy​
      import groovy.json.JsonSlurper

      def json_str = '''{
      "name": "Foo Bar",
      "year": 2018,
      "timestamp": "2018-03-08T00:00:00",
      "tags": [ "person", "employee" ],
      "grade": 3.14 }'''

      def jsonSlurper = new JsonSlurper()
      cfg = jsonSlurper.parseText(json_str)
      println(cfg)

      pipeline

      { agent \{ label 'python' }

      options

      { timestamps() buildDiscarder(logRotator(numToKeepStr: '15', artifactNumToKeepStr: '15')) }

      environment

      { teamName = "devops" appName = "demo" packageName = 'demo' }

      stages {

      stage ('Deploy to dev') {
      steps

      { echo 'Deploying Testtt' }

      }
      }

      }

      The moment it enters the pipeline part, the job errors out. I have attached the detailed logs as an attachment. I went through many blogs and people recommend to use jsonslurperclassic as a workaround and I get that. The same code works fine through our prodcution Jenkins Ecosystem. Is this something related to any plugin version. Why does the job fail even though the am not using the method inside the pipeline. I read an interesting blog post where it mentions Jenkins job tries to save the state of a job in each step by serializing all globally declared variables and since the above one was already serliazed, it errors out.  I am not trying to get a workaorund, if we can get to know why this happens or what are the plugins or configurations in Jenkins that we need to check to get past this issue, that would be of great help.

       

      https://medium.com/@dinanjanagunaratne_93368/when-jenkins-pipeline-fails-unexpectedly-d1d22461b16a

       

        Attachments

          Activity

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              vinodkrishna6 Vinod Radhakrishnan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: