• Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • influxdb-plugin
    • None
    • Jenkins version: 2.346.1
      InfluxDB Version: 3.3
      Windows Server 2016
      InfluxDB: 2.?

      Hello,

      I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code: see attachement PipelineExample.txt

      If I try to push the data to influx I get the response:

      [InfluxDB Plugin] Collecting data...

      http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2[InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

      http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3[InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

      http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4[InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='', database='testbucket')

      http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5[InfluxDB Plugin] Completed.

      I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?

          [JENKINS-69021] Error sending array to influx

          Christoph Hero created issue -

          Aleksi Simell added a comment -

          Hi,

          What data are you actually trying to push? How does it look like? The snippet you pasted has several syntax errors and unknown macro that it's hard to follow what it's supposed to do.

          Sending custom data is documented in the plugin documentation. To put it simply: your data needs a key and a value, so just an array won't work. If your data looks something like this

          [
            {"key1": "value1"},
            {"key2": "value2"},
            {"key3": "value3"}
          ]
          

          then I have to admit that I haven't even tested that, but from the top of my head, I would say that that is not supported. This could be a nice addition to the plugin, but I think it would require a little bit of refactoring.

          Aleksi Simell added a comment - Hi, What data are you actually trying to push? How does it look like? The snippet you pasted has several syntax errors and unknown macro that it's hard to follow what it's supposed to do. Sending custom data is documented in the plugin documentation . To put it simply: your data needs a key and a value, so just an array won't work. If your data looks something like this [ { "key1" : "value1" }, { "key2" : "value2" }, { "key3" : "value3" } ] then I have to admit that I haven't even tested that, but from the top of my head, I would say that that is not supported. This could be a nice addition to the plugin, but I think it would require a little bit of refactoring.
          Christoph Hero made changes -
          Description Original: Hello,

          I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code:
          {quote}import groovy.json.JsonSlurperClassic

          pipeline {
              agent any
              
              environment {
                  JsonCollectorObject = null
                  Test = "Hallo"
              }
              
              stages {
                  stage("ClangTidy") {
                      steps {
                          script {
                              JsonCollectorObject = new net.sf.json.JSONObject()
                              
                              def props = readJSON text: '\{"Failed":  1, "Succeeded":  2, "ProcessedFiles":  3}', returnPojo: false
                              JsonCollectorObject.element("ClangTidy", props)
                          }
                      }
                  }
                  
                  stage("ClangFormat") {
                      steps {
                          script {
                              def props = readJSON text: '\{"Failed":  4, "Succeeded":  5, "ProcessedFiles":  6}', returnPojo: false
                              JsonCollectorObject.element("ClangFormat", props)
                          }
                      }
                  }
                  
                  stage("Array") {
                      steps {
                          script {
                              def props = readJSON text: '[3, 4, 5]', returnPojo: false
                              JsonCollectorObject.element("Array", props)
                          }
                      }
                  }
                  
                  stage("Publish") {
                      steps {
                          script
                          {
                              Test = JsonCollectorObject.toString(3)
                              println(Test)
                              
                              Map dataMap = new JsonSlurperClassic().parseText(JsonCollectorObject.toString())
                              influxDbPublisher(selectedTarget: 'InfluxDB', customDataMap: dataMap)
                          }
                      }
                  }
              
              }
          }
          {quote}
          If I try to push the data to influx I get the response:


          {quote}[InfluxDB Plugin] Collecting data...

          [|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2][InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

          [|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3][InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

          [|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4][InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='[https://influxtest.bu5.digital/]', database='testbucket')

          [|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5][InfluxDB Plugin] Completed.{quote}
          I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?
          New: Hello,

          I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code:
          {quote}import groovy.json.JsonSlurperClassic

          pipeline {
              agent any
              
              environment {
                  JsonCollectorObject = null
                  Test = "Hallo"
              }
              
              stages {
                  stage("ClangTidy") {
                      steps {
                          script {
                              JsonCollectorObject = new net.sf.json.JSONObject()
                              
                              def props = readJSON text: '\{"Failed":  1, "Succeeded":  2, "ProcessedFiles":  3}', returnPojo: false
                              JsonCollectorObject.element("ClangTidy", props)
                          }
                      }
                  }
                  
                  stage("ClangFormat") {
                      steps {
                          script {
                              def props = readJSON text: '\{"Failed":  4, "Succeeded":  5, "ProcessedFiles":  6}', returnPojo: false
                              JsonCollectorObject.element("ClangFormat", props)
                          }
                      }
                  }
                  
                  stage("Array") {
                      steps {
                          script {
                              def props = readJSON text: '[3, 4, 5]', returnPojo: false
                              JsonCollectorObject.element("Array", props)
                          }
                      }
                  }
                  
                  stage("Publish") {
                      steps {
                          script
                          {
                              Test = JsonCollectorObject.toString(3)
                              println(Test)
                              
                              Map dataMap = new JsonSlurperClassic().parseText(JsonCollectorObject.toString())
                              influxDbPublisher(selectedTarget: 'InfluxDB', customDataMap: dataMap)
                          }
                      }
                  }
              
              }
          }
          {quote}
          If I try to push the data to influx I get the response:
          {quote}[InfluxDB Plugin] Collecting data...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2][InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3][InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4][InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='[---|https://influxtest.bu5.digital/]', database='testbucket')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5][InfluxDB Plugin] Completed.
          {quote}
          I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?
          Christoph Hero made changes -
          Description Original: Hello,

          I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code:
          {quote}import groovy.json.JsonSlurperClassic

          pipeline {
              agent any
              
              environment {
                  JsonCollectorObject = null
                  Test = "Hallo"
              }
              
              stages {
                  stage("ClangTidy") {
                      steps {
                          script {
                              JsonCollectorObject = new net.sf.json.JSONObject()
                              
                              def props = readJSON text: '\{"Failed":  1, "Succeeded":  2, "ProcessedFiles":  3}', returnPojo: false
                              JsonCollectorObject.element("ClangTidy", props)
                          }
                      }
                  }
                  
                  stage("ClangFormat") {
                      steps {
                          script {
                              def props = readJSON text: '\{"Failed":  4, "Succeeded":  5, "ProcessedFiles":  6}', returnPojo: false
                              JsonCollectorObject.element("ClangFormat", props)
                          }
                      }
                  }
                  
                  stage("Array") {
                      steps {
                          script {
                              def props = readJSON text: '[3, 4, 5]', returnPojo: false
                              JsonCollectorObject.element("Array", props)
                          }
                      }
                  }
                  
                  stage("Publish") {
                      steps {
                          script
                          {
                              Test = JsonCollectorObject.toString(3)
                              println(Test)
                              
                              Map dataMap = new JsonSlurperClassic().parseText(JsonCollectorObject.toString())
                              influxDbPublisher(selectedTarget: 'InfluxDB', customDataMap: dataMap)
                          }
                      }
                  }
              
              }
          }
          {quote}
          If I try to push the data to influx I get the response:
          {quote}[InfluxDB Plugin] Collecting data...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2][InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3][InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4][InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='[---|https://influxtest.bu5.digital/]', database='testbucket')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5][InfluxDB Plugin] Completed.
          {quote}
          I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?
          New: Hello,

          I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code:
          ----
          import groovy.json.JsonSlurperClassic

          pipeline {
              agent any
              
              environment {
                  JsonCollectorObject = null
                  Test = "Hallo"
              }
              
              stages {
                  stage("ClangTidy") {
                      steps {
                          script {
                              JsonCollectorObject = new net.sf.json.JSONObject()
                              
                              def props = readJSON text: '\{"Failed":  1, "Succeeded":  2, "ProcessedFiles":  3}', returnPojo: false
                              JsonCollectorObject.element("ClangTidy", props)
                          }
                      }
                  }
                  
                  stage("ClangFormat") {
                      steps {
                          script {
                              def props = readJSON text: '\{"Failed":  4, "Succeeded":  5, "ProcessedFiles":  6}', returnPojo: false
                              JsonCollectorObject.element("ClangFormat", props)
                          }
                      }
                  }
                  
                  stage("Array") {
                      steps {
                          script {
                              def props = readJSON text: '[3, 4, 5]', returnPojo: false
                              JsonCollectorObject.element("Array", props)
                          }
                      }
                  }
                  
                  stage("Publish") {
                      steps {
                          script
                          {
                              Test = JsonCollectorObject.toString(3)
                              println(Test)
                              
                              Map dataMap = new JsonSlurperClassic().parseText(JsonCollectorObject.toString())
                              influxDbPublisher(selectedTarget: 'InfluxDB', customDataMap: dataMap)
                          }
                      }
                  }
              
              }
          }
          ----
          If I try to push the data to influx I get the response:
          {quote}[InfluxDB Plugin] Collecting data...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2][InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3][InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4][InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='[—|https://influxtest.bu5.digital/]', database='testbucket')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5][InfluxDB Plugin] Completed.
          {quote}
          I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?
          Christoph Hero made changes -
          Attachment New: PipelineExample.txt [ 58487 ]
          Christoph Hero made changes -
          Description Original: Hello,

          I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code:
          ----
          import groovy.json.JsonSlurperClassic

          pipeline {
              agent any
              
              environment {
                  JsonCollectorObject = null
                  Test = "Hallo"
              }
              
              stages {
                  stage("ClangTidy") {
                      steps {
                          script {
                              JsonCollectorObject = new net.sf.json.JSONObject()
                              
                              def props = readJSON text: '\{"Failed":  1, "Succeeded":  2, "ProcessedFiles":  3}', returnPojo: false
                              JsonCollectorObject.element("ClangTidy", props)
                          }
                      }
                  }
                  
                  stage("ClangFormat") {
                      steps {
                          script {
                              def props = readJSON text: '\{"Failed":  4, "Succeeded":  5, "ProcessedFiles":  6}', returnPojo: false
                              JsonCollectorObject.element("ClangFormat", props)
                          }
                      }
                  }
                  
                  stage("Array") {
                      steps {
                          script {
                              def props = readJSON text: '[3, 4, 5]', returnPojo: false
                              JsonCollectorObject.element("Array", props)
                          }
                      }
                  }
                  
                  stage("Publish") {
                      steps {
                          script
                          {
                              Test = JsonCollectorObject.toString(3)
                              println(Test)
                              
                              Map dataMap = new JsonSlurperClassic().parseText(JsonCollectorObject.toString())
                              influxDbPublisher(selectedTarget: 'InfluxDB', customDataMap: dataMap)
                          }
                      }
                  }
              
              }
          }
          ----
          If I try to push the data to influx I get the response:
          {quote}[InfluxDB Plugin] Collecting data...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2][InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3][InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4][InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='[—|https://influxtest.bu5.digital/]', database='testbucket')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5][InfluxDB Plugin] Completed.
          {quote}
          I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?
          New: Hello,

          I am trying to push some customData to influxdb and everything works fine until I try to use an array in my data. To investigate the problem I wrote an small pipeline example with the following code: see attachement [^PipelineExample.txt]

          If I try to push the data to influx I get the response:
          {quote}[InfluxDB Plugin] Collecting data...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-2][InfluxDB Plugin] Custom data map found. Writing to InfluxDB...

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-3][InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-4][InfluxDB Plugin] Publishing data to target 'InfluxDB' (url='[—|https://influxtest.bu5.digital/]', database='testbucket')

          [http://---/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5|http://ntserv30:8080/blue/organizations/jenkins/Pipeline-Test/detail/Pipeline-Test/84/pipeline/#step-39-log-5][InfluxDB Plugin] Completed.
          {quote}
          I seems so that your plugin has a problem to push array data to influx. Why? Is it forbidden? How can I solve my problem?
          Christoph Hero made changes -
          Attachment New: PipelineExample-1.txt [ 58490 ]
          Christoph Hero made changes -
          Attachment Original: PipelineExample.txt [ 58487 ]
          Christoph Hero made changes -
          Attachment Original: PipelineExample-1.txt [ 58490 ]
          Christoph Hero made changes -
          Attachment New: PipelineExample.txt [ 58491 ]

            aleksisimell Aleksi Simell
            ckak07 Christoph Hero
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: