It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to export issues and their links via JSON instead of CSV

Problem: The built-in JIRA Export to CSV only list the linked issue's key, but not the link type. This is a known limitation. For example, see here: Known Issue.

I am performing an export of many issues in order to import them via CSV to another JIRA server, and I need to know the link type.

The solution is to export to JSON.

Step 1: Create an input JSON (save it in file input.json). Note that you cannot retrieve more than 1000 issues in one call, so you need to limit the search and perform subsequent calls if you have more than 1000.

{
"jql": "project = \"Your project name here\" AND key >= FOO-1 AND key < FOO-1001 order by key asc",
"maxResults": 1000,
"fields": [
"issuetype",
"status",
"summary",
"issuelinks",
"customfield_11280",
...
]
}

Step 2: Run curl on the JIRA server's REST API with the above JSON. This is on Linux:

curl -k -u user:password -X POST -H "Content-Type: application/json" --data @infile.json https://jira.acme.com/rest/api/2/search | jq '.' > outfile.json

Step 3: The output file will have all the issues and in each, the fields you've specified:

{
"expand": "schema,names",
"startAt": 0,
"maxResults": 1000,
"total": 502,
"issues": [
{
"expand": "operations,editmeta,changelog,transitions,renderedFields",
"id": "140026",
"self": "https://acme.com/rest/api/2/issue/140026",
"key": "FOO-1",
"fields": {
"issuetype": {
"self": "https://jira.acme.com/rest/api/2/issuetype/26",
"id": "26",
"description": "",
"iconUrl": "https://jira.acme.com/images/icons/issuetypes/improvement.png",
"name": "CCB",
"subtask": false
},
"customfield_11280": {
"self": "https://jira.acme.com/rest/api/2/customFieldOption/12252",
"value": "No",
"id": "12252"
},
"issuelinks": [
{
"id": "59700",
"self": "https://jira.acme.com/rest/api/2/issueLink/59700",
"type": {
"id": "10020",
"name": "Related",
"inward": "Related",
"outward": "Related",
"self": "https://jira.acme.com/rest/api/2/issueLinkType/10020"
},
"inwardIssue": {
"id": "139870",
"key": "NGAC-9643",
"self": "https://jira.acme.com/rest/api/2/issue/139870",
"fields": {
"summary": "BCP || Cases still exists in queue after case was closed",
"status": {
"self": "https://jira.acme.com/rest/api/2/status/6",
"description": "The issue is considered finished, the resolution is correct. ",
"iconUrl": "https://jira.acme.com/images/icons/statuses/closed.png",
"name": "Closed",
"id": "6",
"statusCategory": {
"self": "https://jira.acme.com/rest/api/2/statuscategory/3",
"id": 3,
"key": "done",
"colorName": "green",
"name": "Done"
}
},
"priority": {
...,
"id": "3"
},
"issuetype": {
...
}
}
}
}
],
# more fields here
}, # end of the 1st issue here
{ # start of next issue
...
}
] # end of all issues
} # end of the JSON


 Step 4: If you need your output as CSV, use your favorite programming/scripting language to transform the JSON to CSV. This is basically what the JIRA UI does when you do Export to CSV...

Enjoy.

 

0 comments

Comment

Log in or Sign up to comment
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

676 views 7 0
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you