Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting linked issues from Jira with Python

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?

like image 710
Lormitto Avatar asked Oct 30 '25 14:10

Lormitto


1 Answers

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)
like image 97
Tom Slee Avatar answered Nov 01 '25 04:11

Tom Slee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!