I am trying to create a JIRA ticket using curl POST method, but the variable substitution is not happening properly in TODAY_DATE
variable. If i remove that it is working fine. ANy hint on how this can be solved?
Below is my code where only TODAY_DATE
substition isnt working and failing with below error
#!/bin/bash
JIRA_CREDS="XXX:YYY"
JIRA_PROJECT="OPS"
JIRA_URL="http://jira/jira/rest/api/2/issue/"
JIRA_CONTENT_TYPE="Content-Type: application/json"
DATE_1=`date +"%d/%b/%y %r" | cut -d":" -f1`
DATE_2=`date +"%d/%b/%y %r" | cut -d":" -f2`
DATE_3=`date +"%d/%b/%y %r" | cut -d":" -f3 | cut -d" " -f2`
TODAY_DATE=`echo "${DATE_1}:${DATE_2} ${DATE_3}"`
curl -D- -u "$JIRA_CREDS" -X POST --data '{
"fields": {
"project":
{
"key": "'$JIRA_PROJECT'"
},
"summary": "Security patch update",
"description": "The instances need to be updated via yum.",
"customfield_13339": { "value": "Bamboo" },
"customfield_13338": { "value": "Approved" } ,
"customfield_13337": [{ "value": "Team" }],
"customfield_13331": [{ "value": "SITTR" }],
"customfield_13334": { "value": "'$TODAY_DATE'" },
"issuetype": {
"name": "Tech Task"
}
}
}' -H "$JIRA_CONTENT_TYPE" "$JIRA_URL"
curl: (7) Failed to connect to 0.0.0.11: Invalid argument
curl: (23) Failed writing header