Unable to replace variable inside curl query

federico October 27, 2022

I would like to execute a curl query inside my bitbucket pipeline.
The issue I have is using the variable in the pipeline.
Here is my code


- |-
curl --location --request POST "https://xxx.atlassian.net/rest/api/3/issue/"${TICKET_NAME}"/comment" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Basic $JIRA_API_TOKEN" \
-H "Cookie: atlassian.xsrf.token=$JIRA_COOKIE_TOKEN" \
--data-raw "{ \"body\": {\"type\": \"doc\",\"version\": 1,\"content\": [{\"type\": \"paragraph\",\"content\": [{\"text\": \"$PREVIEW_LINK\",\"type\": \"text\"}]}]}}"

The problem is `TICKET_NAME`, `PREVIEW_LINK`, `JIRA_COOKIE_TOKEN`, `JIRA_API_TOKEN` are not replaced....

I tried

"https://xxx.atlassian.net/rest/api/3/issue/"${TICKET_NAME}"/comment"
"https://xxx.atlassian.net/rest/api/3/issue/$TICKET_NAME/comment"
"https://xxx.atlassian.net/rest/api/3/issue/\"$TICKET_NAME\"/comment"
"https://xxx.atlassian.net/rest/api/3/issue/"$TICKET_NAME"/comment"

But nothing seems to work

This work inm my BASH

- >-
curl --location --request POST "https://adasiaholdings.atlassian.net/rest/api/3/issue/$TICKET_NAME/comment" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Basic $JIRA_API_TOKEN" \
-H "Cookie: atlassian.xsrf.token=$JIRA_COOKIE_TOKEN" \
--data-raw "{ \"body\": {\"type\": \"doc\",\"version\": 1,\"content\": [{\"type\": \"paragraph\",\"content\": [{\"text\": \""$PREVIEW_LINK"\",\"type\": \"text\"}]}]}}"

but return

> curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) nested brace in URL position 11:
{ "body": {"type": "doc","version": 1,"content": [{"type": "paragraph","content": [{"text": "","type": "text"}]}]}}

in the pipeline

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 28, 2022

Hi @federico,

Please use ${TICKET_NAME}, ${PREVIEW_LINK}, ${JIRA_COOKIE_TOKEN} and ${JIRA_API_TOKEN}

The ${TICKET_NAME} in the URL shouldn't be within quotes.

Below is a curl command (with a few different variables) that works for me in Pipelines:

- curl -v --request POST --url "https://XXXX.atlassian.net/rest/api/3/issue/${issueKey}/comment" --user "${JiraEmail}:${JiraToken}" --header 'Accept:application/json' --header 'Content-Type:application/json' --data-raw "{\"body\":{\"type\":\"doc\",\"version\":1,\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\""${PREVIEW_LINK}"\",\"type\":\"text\"}]}]}}"

Please feel free to let me know if that works for you or if you're still seeing errors.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events