Pre-Post Build Command Runner run issue

Running Bamboo 5.15.3 and just got Pre-Post Build Command runner installed and trying to use it to create a jira bug upon failed buid. Bamboo is on a windows server and wanting to execute the command on the server, not a remote. Running the following command

"C:\Program Files\CustomMEM\Executables\curl" -D- -u username:password -X POST -d "{\"fields\": {\"project\": {\"key\": \"MATH\"}, \"summary\": \"${bamboo.buildPlanName} - Build: ${bamboo.buildNumber} Change List: ${bamboo.repository.revision.number}\", \"description\": \"Link to the failed build: ${bamboo.buildResultsUrl}\", \"issuetype\": {\"name\": \"Bug\"}}}" -H "Content-Type: application/json" https://<jiraServer>/rest/api/2/issue/

 

When I run the build it bombs out with 

curl: (6) Could not resolve host: "summary"
28-Apr-2017 10:17:57 curl: (3) Port number ended with ' '
28-Apr-2017 10:17:57 curl: (6) Could not resolve host: "description"
28-Apr-2017 10:17:57 curl: (3) Port number ended with ' '
28-Apr-2017 10:17:57 curl: (6) Could not resolve host: "issuetype"
28-Apr-2017 10:17:57 curl: (3) [globbing] unmatched brace in column 1
28-Apr-2017 10:17:57 curl: (3) [globbing] unmatched close brace/bracket in column 6

So I took the command that was generated after Bamboo subsititued the variables and ran it on command line and it worked perfectly. 

Any and all help would be appreciated and thanks in advance!

1 answer

0 votes
Elias Zeidan Atlassian Team Aug 16, 2017

Hi Matt!

Thanks for your Question. It looks like the issue here is that the quotes inside the data (eg: \"fields\") are not being properly escaped for the Script task. 

Could you please try the following:

  • Use two backslashes instead of one so that the backslash is escaped when the code is read by Bamboo and then the double quote is escaped when sent to curl
    "C:\Program Files\CustomMEM\Executables\curl" -D- -u username:password -X POST -d "{\\\"fields\\\": {\\\"project\\\": {\\\"key\\\": \\\"MATH\\\"}, \\\"summary\\\": \\\"${bamboo.buildPlanName} - Build: ${bamboo.buildNumber} Change List: ${bamboo.repository.revision.number}\\\", \\\"description\\\": \\\"Link to the failed build: ${bamboo.buildResultsUrl}\\\", \\\"issuetype\\\": {\\\"name\\\": \\\"Bug\\\"}}}" -H "Content-Type: application/json" https://<jiraServer>/rest/api/2/issue/
  • Enclose the data in single quotes:
    "C:\Program Files\CustomMEM\Executables\curl" -D- -u username:password -X POST -d '{\"fields\": {\"project\": {\"key\": \"MATH\"}, \"summary\": \"${bamboo.buildPlanName} - Build: ${bamboo.buildNumber} Change List: ${bamboo.repository.revision.number}\", \"description\": \"Link to the failed build: ${bamboo.buildResultsUrl}\", \"issuetype\": {\"name\": \"Bug\"}}}' -H "Content-Type: application/json" https://<jiraServer>/rest/api/2/issue/

Thanks!

Elias 
Bamboo Support

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

445 views 8 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you