网站的集约化建设,如何建立网站和网页,湖南省建设工程信息网官网,伍佰亿网站怎么做文章目录 1.插件安装2.请求pipline语法3.插件方式实现4.乱码问题解决5.值得注意 1.插件安装
需要安装HTTP Request 插件#xff1b;安装方式不介绍。
2.请求pipline语法
官网链接#xff0c;上面有详细语法#xff1a;https://plugins.jenkins.io/http_request/
附一个d… 文章目录 1.插件安装2.请求pipline语法3.插件方式实现4.乱码问题解决5.值得注意 1.插件安装
需要安装HTTP Request 插件安装方式不介绍。
2.请求pipline语法
官网链接上面有详细语法https://plugins.jenkins.io/http_request/
附一个demo脚本脱敏处理 stage(开启推送) {steps {script {// 请求sonar获取信息echo 请求sonar获取信息def response httpRequest \httpMode: GET,ignoreSslErrors: true,contentType: APPLICATION_JSON,// requestBody: groovy.json.JsonOutput.toJson(requestBody1),url: http://localhost:9000/println(Response: response.content)println()println(response msg)def props readJSON text: response.contentdef bugs props[measures][0][history][0][value]def code_smells props[measures][1][history][0][value]def vulnerabilities props[measures][2][history][0][value]println(bugs: ${bugs})println(code_smells: ${code_smells})println(vulnerabilities: ${vulnerabilities})// robotdef response2 httpRequest \httpMode: POST,quiet: true,ignoreSslErrors: true,contentType: APPLICATION_JSON_UTF8,requestBody: {card: {elements: [{tag: div,text: {content: **代码**扫描结果xxxxxxxx。,tag: lark_md}},{actions: [{tag: button,text: {content: 更多详细信息 :玫瑰:,tag: lark_md},type: default,url: http://localhost:9000/,value: {}}],tag: action}],header: {title: {content: 静态代码扫描,tag: plain_text}}},msg_type: interactive},url: https://xxxxxxxx}}}
3.插件方式实现
直接在构建里找到插件选择就行不描述
4.乱码问题解决
编码字符集问题解决起来代码pipline方式比较难解决就到插件里配置看是否会发生同样问题发现一样问题在插件里解决 选择报文类型 contentType: ‘APPLICATION_JSON_UTF8’ 于是 在pipline里 contentType 类型做对应修改即可。
5.值得注意
def props readJSON text: response.content 这个是解析json文件用的这个需要安装一个插件 应该是这个 忘记了 Pipeline Utility Steps。百度一下就知道了。