how to see epic/issue relationship using jira-python's search_issues

carmella_smith September 23, 2019

I can get epics with the wonderful jira-python project liks this:
jira_connection = JIRA(constants.JIRA_URL, basic_auth=(constants.JIRA_USER_NAME, constants.JIRA_PASSWORD))
jql_query = 'issuetype=Epic'
epics = jira_connection.search_issues(jql_query)
and I can get issues with a different jql_query:
jql_query = 'project=UI'
Of all the fabulous information that comes back for one epic or for one issue, what element indicates that the issue is in the epic, or that the epic contains the issue?
I've been looking both ways, from epic to issue and from issue to epic, particularly searching for the id of one in the data elements of the other, but no luck.
For example, my sample epic has an id of 302486. When examining an issue in the epic, known to be in the epic as seen in the regular Jira UI, I hoped to find an element on the issue with a value of 302486, the epic's id.
Alas, I'm not finding one.
I know that I can use the REST API and loop through all the epics with a REST API call for each one to get their issues, but I'd rather not convert my project to REST API and give up the fantastic ease of use of jira-python.
Plus, I'm harvesting data, so having an API call for each epic isn't optimal
Is there any element returned by search_issues in jira-python that will give the epic to issue or issue to epic relationship? Or any more clever idea?
Thanks so much for a great tool, and any suggestions you may have for a solution.

1 answer

1 accepted

0 votes
Answer accepted
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 24, 2019

Hi @carmella_smith 

 

You could try this :

proj = jira.search_issues("'Epic Link' is not EMPTY and project = 'your project(s)'")

It will list all issue that belong to an epic. After that with a loop you can access to the epic issue number. 

 

The code below give you access to the epic link issue number.

for i in proj:
print(i.fields.customfield_10405)

I think with loop you can get more informations if you need too

Hope this helps.

carmella_smith September 24, 2019

Hello Mohamed,

Thanks so much for your post.  Alas, we don't have any customfield_10405 at our local installation.  I'll talk to our site admin to find out about it.  Many thanks.

Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2019

Hi Carmella,

 

If you want to know the id of the epic link field you need to read this documentation :

https://confluence.atlassian.com/jirakb/how-to-find-id-for-custom-field-s-744522503.html

 

Just replace customfield_10405 with the good id.

 

Hope this helps

Like # people like this
carmella_smith September 25, 2019

Hello Mohamed,

What a great page that documentation is!  It told me everything I needed to know, and I'm now unstuck, thanks to you.  Blessings on you for taking the time to share you knowledge with me; I appreciate it.

 

Thanks,

Carmella

Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 26, 2019

Hello Carmella,

 

I'm so glad i could help you !!

Suggest an answer

Log in or Sign up to answer