Getting linked issues from Jira with Python

11,030

I can't give a complete answer, but issue.fields.issuelinks is not a list of issues, it is a list of links. Here is one example of use:

for link in issue.fields.issuelinks:
    if hasattr(link, "outwardIssue"):
        outwardIssue = link.outwardIssue
        print("\tOutward: " + outwardIssue.key)
    if hasattr(link, "inwardIssue"):
        inwardIssue = link.inwardIssue
        print("\tInward: " + inwardIssue.key)
Share:
11,030
Lormitto
Author by

Lormitto

Updated on June 25, 2022

Comments

  • Lormitto
    Lormitto about 2 years

    I try to get linked issues from Jira using Python. It seems to be tricky as number of linked issues in particular issue I am getting is correct but linked issues are not those I am expecting (veryfied with Jira web interface). They seem to be some other issues, even from different project.

    My purpose here is to get all linked issues for each issue which has them and check if linked issues have particular status.

    Here is what I do:

    results = jira.search_issues('here query')  
    for issueId in results:
        issue = jira.issue(issueId)
        if (issue.fields.issuelinks): 
            for issueLinked in issue.fields.issuelinks:
                if(jira.issue(issueLinked).fields.status != "Done" and jira.issue(issueLinked).fields.status != "Closed"):
                    print("id: ", jira.issue(issueLinked).id)
                    print("key: ", jira.issue(issueLinked).key)
                    print("status: ", jira.issue(issueLinked).fields.status)
                    print("summary: ", jira.issue(issueLinked).fields.summary)
    

    Did you perhaps experience similar problem?