Pre-Post Build Command Runner run issue

mluebber April 28, 2017

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 (they/them)
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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
TAGS
AUG Leaders

Atlassian Community Events