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

Not able to send data to Influx DB using Groovy Closure

      I am trying to send the data from a groovy map in iterations to influx DB. The data is collected using 

       

      def testCaseDuration = ''
      def testCaseDetails = [:]
      
      def xmlText = new XmlSlurper().parseText(xml)
      
      xmlText.testsuite.testcase.each { testcase ->
          testCaseDuration = testcase['@time'].toString()
          testCaseDuration = testCaseDuration.substring(testCaseDuration.lastIndexOf(":") + 1)
          testCaseDetails[testcase.@name] = testCaseDuration
      }
      
       
      
      testCaseDetails.each { testcase, duration ->
          println "testCaseDetails in loop: TestCase Name: ${testcase} = TestCase Duratiom ${duration}"
      
          def testField = [:]
          def testTag = [:]
          def testDataMeasurementFields = [:]
          def testDataMeasurementTags = [:]
          testField['total'] = testcase
          testField['passed'] = duration
          testTag['infra'] = 'aws'
          testTag['space'] = 'dev'
          testDataMeasurementFields['apitest1'] = testField
          testDataMeasurementTags['apitest1'] = testTag
      
          influxDbPublisher(selectedTarget: 'jenkins', customDataMap: testDataMeasurementFields,
          customDataMapTags: testDataMeasurementTags)
      
      }
      

       

      The first insertion to influx DB happens and following which it gives the below error 

       
      20:14:29 in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@5fe1b10b*20:14:29* Caused: java.io.NotSerializableException: groovy.util.slurpersupport.NodeChild

       

      How do i push the data to influxDB using the loop or closure in jenkins pipeline

          [JENKINS-62772] Not able to send data to Influx DB using Groovy Closure

          Aleksi Simell added a comment -

          karthik_hg Does your script work if you comment out the call for InfluxDBPublisher()?

          The InfluxDBPublisher call in itself looks good, except that I think you'd overwrite your own data for each iteration. Time and tags are the primary key in InfluxDB and you're using the same tags for each iteration and you're not changing the time.

          I'm not that familiar with groovy looping, that I could say for certain, but your error could be in your loop syntax. Although it might be technically correct, it might be non-serializable, thus giving you the error.

          Aleksi Simell added a comment - karthik_hg Does your script work if you comment out the call for InfluxDBPublisher()? The InfluxDBPublisher call in itself looks good, except that I think you'd overwrite your own data for each iteration. Time and tags are the primary key in InfluxDB and you're using the same tags for each iteration and you're not changing the time. I'm not that familiar with groovy looping, that I could say for certain, but your error could be in your loop syntax. Although it might be technically correct, it might be non-serializable, thus giving you the error.

            vjuranek vjuranek
            karthik_hg Karthik HG
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: