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

Problem: The built-in JIRA Export to CSV only lists 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 that I devised is to export to JSON instead of CSV.

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 issues.

{
"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 and you need to have 'jq' installed:

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 that 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.

 

3 comments

Michael Gembalski November 6, 2019

Hi there,

is there a way to use this kind of export for exporting remote links?

Amir Katz (Outseer)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2019

On cursory check, the answer seems to be negative. When I'm retrieving an issue via REST API, like this:

https://my-jira-server/rest/api/2/search?jql=key=top-3765&fields=issuelinks

it only returns the same-server links.

In the browser, I do see the external links as well.

I will research it further sometimes later.

Amir Katz (Outseer)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2020

Quick update: we're running Jira 8.8.1 (on-prem) and the REST API call still does not retrieve remote links.

Like Sébastien Lesourd likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events