Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do i link existing Epic issues with a csv file

Kenert Künnapuu August 27, 2024

I have existing Jira Epic issues. 211 to be exact. I have defined the relationships between them in a google sheets document that i can export as a csv. I have two columns. Column A contains the "parent" and column B contains the "child" values are issueID-is.

csv Picture.png

 

Can and how i can use this CSV file to link all of these issues to each other. There are over 700 links that need to be made and I tried doing this in batches of 240. Import csv also requires a summary, i placed a dummy value in there since I am not creating any new issues. Just trying to link existing Epic-s to each other. 

jiratest1.png

 

When I try to do this, it gives me warnings. That some issues were not found. But i checked and all the issueID-s actually exist. So is there antoher/better way to go about this or is this even possible?

 

 

 

MapValues.png

 

If i look at the detailided validation........ it tries to create new issues. But i already have all these issues. Can they be linked togheter?

1 answer

0 votes
Marc - Devoteam
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.
August 27, 2024

Hi @Kenert Künnapuu 

Do you want to achieve a parent - child relation or an issue link relation?

Issue Id is for parent child relation and blocks is for an issue link relation.

For parent child relation, you need 3 columns in your csv, issue id, issue type and parent.

Also see the KB article on CSV import; import-data-from-a-csv-file 

Issue linking is done different, see; how-to-import-issue-links-from-a-csv-file-in-jira (the article says server/dc only, but the same applies for Cloud).

Kenert Künnapuu August 27, 2024

I want to achive issue link relation. Blocks

Marc - Devoteam
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.
August 27, 2024
Jim Knepley - ReleaseTEAM
Atlassian Partner
August 27, 2024

I think this is the right answer, but if it doesn't work because of the summary field requirement you can always roll your own with the issue link API.

Kenert Künnapuu August 27, 2024

If go with the "how to import isse links from a csv file in jira" it creates new issues. My problem is that the issues already exist. And existing issues need to be linked

 

Jim Knepley - ReleaseTEAM
Atlassian Partner
August 28, 2024

OK. This is quick-and-dirty, but this Python will read from a CSV file and link the issues in the abovementioned columns. You'll need to make changes to your own domain name and authentication.

 

 

import csv
import json

import requests

jira_api = requests.Session()
jira_api.headers.update({"Accept": "application/json", "Content-Type": "application/json"})
jira_api.auth = ("email", "api_token")
atlassian_domain = "your-domain.atlassian.net"

def
link_issue(inward, outward, link_type="Blocks"):
    response = jira_api.request(
        "POST",
        f"https://{atlassian_domain}/rest/api/2/issueLink",
        data=json.dumps(
            {
                "inwardIssue": {"key": inward},
                "outwardIssue": {"key": outward},
                "type": {"name": link_type},
            }
        )
    )
    response.raise_for_status()

with open("links.csv") as links_csv:
    reader = csv.DictReader(links_csv)
    for line in reader:
        link_issue(line["IssueId"], line["Blocks"])
        print(f"{line["IssueId"]} > {line["Blocks"]}")
Like Kenert Künnapuu likes this
Kenert Künnapuu August 28, 2024

Thank you for the script

 

 

Suggest an answer

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

Atlassian Community Events