【问题标题】:Jenkins Pipeline send HttpRequestJenkins Pipeline 发送 HttpRequest
【发布时间】: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


    【解决方案1】:

    您是否尝试过 $GIT_COMMIT 参数? (如果您在 Jenkins 中使用 Git 插件)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-18
      • 2019-08-10
      • 1970-01-01
      • 2017-11-23
      • 1970-01-01
      相关资源
      最近更新 更多