Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,214
Community Members
 
Community Events
184
Community Groups

Unable to replace variable inside curl query

Edited

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.
Oct 28, 2022 • edited

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