I am modifying script for bitrise and met the problem that I cannot compare string with spaces, select( .to.name == \"$to_status\"
returns false, where .to.name is "ready for qa" and to_status is "ready for qa"
TO_STATUS="Ready to QA"
transition_id=$(curl -s \
-H "Authorization: Basic $token" \
"$jira_url/rest/api/2/issue/$task/transitions" | \
jq -r ".transitions[] | select( .to.name == \"$to_status\" ) | .id")
I tried to adopt the solution from this post, but without any luck
transition_id=$(curl -s \
-H "Authorization: Basic $token" \
"$jira_url/rest/api/2/issue/$task/transitions" |
jq -r --arg to_status "$TO_STATUS" '
.transitions[]
| select(.to."name"==$to_status)
| .id')
json
{
"expand": "transitions",
"transitions": [
{
"id": "11",
"name": "Backlog",
"to": {
"name": "Backlog",
"id": "10510"
}
},
{
"id": "51",
"name": "Ready to QA",
"to": {
"name": "Ready for QA",
"id": "10209"
}
}
]
}