zoukankan      html  css  js  c++  java
  • Jenkins Pipeline调用 httpRequest插件提交Http请求

    #!groovy
    def call(reqMode,url,reqBody){
      //调用httpRequest插件
      if(reqMode == 'POST'){
    
        response = httpRequest customHeaders: [[name: 'Content-Type', value: 'application/x-www-form-urlencoded;charset=UTF-8']], //使用自定义header,避免默认的charset=ISO-8859-1导致中文乱码。先使用contentType: 'APPLICATION_FORM',在输出内容中会显示Conten-Type内容
                     // contentType: 'APPLICATION_FORM', //POST请求必须使用的格式
                     httpMode: "POST",
                     requestBody:reqBody,
                     url:url
      }
    
      if(reqMode == 'GET'){
        response = httpRequest contentType: 'APPLICATION_JSON',
                     httpMode: "GET",
                     customHeaders: [
                             [name: "TOKEN", value: "B456skjasdjkf="]
                     ],
                     url:url
      }
    
      return [response.status,response.content]
    }


    def data='你好,张三' //如果data中包含字符&,则需要用 %26 代替
    def url='http://msg.x.com/msg/rcemsg'
    def textmod = "key=$key&content=$data"
    textmod = new String(textmod.getBytes(),"UTF-8")
    HttpReq('POST',url,textmod)

     
  • 相关阅读:
    FPGA市场潜力有几多?
    FPGA前世今生(四)
    FPGA前世今生(三)
    FPGA前世今生(二)
    FPGA前世今生(一)
    嵌入式视频处理考虑(二)
    常用Linux操作命令
    混合开发学习路线
    Eclipse使用
    ECS的配置与使用
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/13952860.html
Copyright © 2011-2022 走看看