随着对詹金斯的http请求的插件(我运行1.643)的v1.8.10,现在在请求发布一个身体支撑 - 所以这thread不适用。我想知道如何在管道(V2.1)Groovy脚本使用此功能?摘录发电机不包括这一新的领域,所以我没有例子来蓄客的。
我曾尝试过各种方法来获得JSON数据到请求的身体,但我的Tomcat服务器总是返回HTTP 400状态码:The request sent by the client was syntactically incorrect.
事情我已经尝试:
def toJson = {
input ->
groovy.json.JsonOutput.toJson(input)
}
def body = [
displayName: [
text: "smoke test"],
description: [
text: "for smoke testing"],
genusTypeId: "type"
]
response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: toJson(body), url: "https://${host}", validResponseCodes: '200'
def body = [
displayName: [
text: "smoke test"],
description: [
text: "for smoke testing"],
genusTypeId: "type"
]
response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: body, url: "https://${host}", validResponseCodes: '200'
response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: "{\"displayName\":{\"text\":"smoke test\"},\"description\":{\"text\":\"for smoke testing\"}, \"genusTypeId\":\"type\"}", url: "https://${host}", validResponseCodes: '200'
response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: "'{\"displayName\":{\"text\":"smoke test\"},\"description\":{\"text\":\"for smoke testing\"}, \"genusTypeId\":\"type\"'}", url: "https://${host}", validResponseCodes: '200'
扫描http-request
库中的代码,好像设置这个标志应该工作。我不知道该怎么管道插件/詹金斯插件工作,所以我不知道如果管道 - > http请求的代码解释这种新的参数?有人能指出我如何才能让与请求主体与管道的工作,或者我需要修改Pipline插件代码来进行连接的帖子吗?