【发布时间】:2019-09-27 09:54:34
【问题描述】:
我正在尝试在 Jenkins 管道中发送 HTTP 发布请求。 我试图在 post body 请求中传递变量,同时我得到 500 异常。
但是当我像 "revision": 123456 这样的硬编码时它工作正常。
如何在 requestbody 中传递 gitCommit 变量
env.gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
httpRequest acceptType: 'APPLICATION_JSON',
contentType: 'APPLICATION_JSON',
consoleLogResponseBody: true,
customHeaders: [[maskValue: true, name: 'X-Api-Key', value: 'xxxxxxxxxxxx']],
httpMode: 'POST',
ignoreSslErrors: true,
requestBody: '''{
"deployment": {
"revision": ${gitCommit}
}
}''',
responseHandle: 'NONE',
url: 'https://api.newrelic.com/v2/applications/xxxxxxx/deployments.json'
【问题讨论】:
标签: jenkins jenkins-pipeline httprequest newrelic jenkins-groovy