I am trying to make a New Relic deployment API call as a Jenkins build step using the Groovy pipeline. I'm having trouble because of the use of both single and double quotes within the shell ('sh') command on the groovy script. Whenever I execute the following:
node {
//...
def json = '''\
{"deployment": {"revision": "v1","user": "me"}}'
'''
sh "curl -o /dev/null -s -X POST 'https://api.newrelic.com/v2/applications/[redacted]/deployments.json' \
-H 'X-Api-Key:[redacted]' \
-H 'Content-Type: application/json' \
-d '${json}'"
// ...
}
I get an error in Jenkins that says:
/var/lib/jenkins/jobs/[redacted]/workspace@tmp/durable-0f6c52ef/script.sh: line 2: unexpected EOF while looking for matching `''