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,466,406
Community Members
 
Community Events
176
Community Groups

i want to pass my variable in to the JSON object of JIRA API

Edited

i want to pass my variable in to the JSON object of JIRA API . Here i want to pass this variable summary into the fields .

var summary = " Create ticket"

 "fields": { "summary": "Summary" ,"issuetype": { "id": "1" }, assignee": { "name": "abc" },                        "project": {"id": "23601"}  }

Kindly share the format to pass the variable into this JSON .

Thanks in Advance .

2 answers

I came across this thread while looking for solution to my problem. I am not sure if kmjira was also facing the same problem. 

 

I wanted to define a variable and then use it in the jql search query while running this code via Jenkins build step. I was able to do this the following way. I have used two variables OlderThan and jira_sql. The JSON output will be recorded in file OpenTickets.txt

 

OlderThan=30

jira_jql="Project = PROJECTNAME AND status not in (closed, resolved, done) AND created < -${OlderThan}d ORDER BY created ASC"


if [[ ! -z "${jira_jql}" ]]
then
curl --location --request POST "https://jira.xyz.com/rest/api/2/search?pretty=true" \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ZXRhbzpFdGFvQDEyMw==' \
--data '{
"jql": "'"${jira_jql}"'",
"startAt":0,
"maxResults":1000,
"fields":["key","issuetype","summary","priority","status","created","updated","assignee"]
}' > /tmp/OpenTickets.txt

PS: Posted my solution here so that may be it can help someone else like me.

I find it strange to see this important question not answered even after 10 months!!! I found similar questions in the community, also not answered!!!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS

Atlassian Community Events