美文网首页
jenkins pipeline 查询influxdb数据

jenkins pipeline 查询influxdb数据

作者: _fishman | 来源:发表于2020-06-08 10:42 被阅读0次

    原始influxdb数据

    {
      "results": [
        {
          "statement_id": 0,
          "series": [
            {
              "name": "version",
              "columns": [
                "time",
                "image_id"
              ],
              "values": [
                [
                  "2020-06-08T01:57:23.242796382Z",
                  "dev-xxx"
                ]
              ]
            }
          ]
        }
      ]
    }
    
    import java.net.URLEncoder
    
    pipeline{
    agent { node { label "master"}}
        
    stages{
        stage("Build"){
            steps{
                script{
         
                def query = java.net.URLEncoder.encode('SELECT image_id FROM "version" WHERE "profile"=\'prd\' AND "product"=\'pay\' AND "srv_name"=\'demo\' order by time desc limit 1', "UTF-8")
                
                apiUrl = "http://localhost:8086/query?db=mydb&pretty=true&q=${query}"
                response = httpRequest contentType: 'APPLICATION_JSON' , url: "${apiUrl}"
    
                def response = readJSON text: """${response.content}"""      
                image_id = response.results[0].series[0].values[0][-1]
                println(image_id)
    
                    }
                }
            }
        }
    }
    
    

    相关文章

      网友评论

          本文标题:jenkins pipeline 查询influxdb数据

          本文链接:https://www.haomeiwen.com/subject/fehltktx.html