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 vote
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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

78 views 0 5
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