我正在尝试在Jenkins管道中发送HTTP发布请求。我试图在后正文请求中传递变量,但这样做却得到500个异常。
但是当我使用“修订”之类的硬代码时: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'
您是否尝试过$ GIT_COMMIT参数? (如果您在Jenkins中使用Git插件)