-1

I am trying to send HTTP post request in Jenkins pipeline. I am trying to pass variable in post body request, while doing so i get 500 exception.

But when i hard code like "revision": 123456 it works fine.

How can i pass gitCommit variable inside requestbody

  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'
VIJ
  • 1,516
  • 1
  • 18
  • 34

1 Answers1

0

Did you try $GIT_COMMIT parameter maybe? (if You are using Git plugin in Jenkins)