Using Jira's Python API, how can I set the epic link for an issue?
Asked Answered
K

2

6

I am trying to assign issues to epics using Jira's python API. From the documentation, I found there is an add_issues_to_epic method in the GreenHopper class, but it doesn't seem to work for me. I have the following so far

from jira.client import JIRA
from jira.client import GreenHopper

jira = JIRA(options, basic_auth=(username, password))
greenhopper = GreenHopper(options, basic_auth=(username, password))
epicLink = 'IR-345'
issuesToAdd = ['IR-1459']
greenhopper.add_issues_to_epic(epicLink, issuesToAdd)

But that gives me the error that add_issues_to_epic is not found for class GreenHopper. I've tried jira.add_issues_to_epic(epicLink, issuesToAdd), but that gives me the same error.

What am I doing wrong?

Kilmer answered 24/2, 2014 at 21:0 Comment(2)
probably using an old version of jira-python I suspect. Check the function exists in the your local jira/client.py fileDooley
Yup, that solved it...thanks! I had to upgrade to the new version of the API.Kilmer
K
2

I just had to upgrade to the new version of the API.

Kilmer answered 25/4, 2014 at 16:57 Comment(0)
M
2

As of January 2022, add_issues_to_epic is not supported for next-gen projects (you'll get this error: "Jira Agile Public API does not support this request").

https://ecosystem.atlassian.net/browse/ACJIRA-1634 explains how to do it now:

Move issues to epic - Edit the issue and set the parent field. Example: {"fields":{"parent":{"id":"11111"}}}

Code example:


issue = jira.create_issue(project='PRJ',
                          summary='Heisenbug',
                          description='Can't reproduce it.',
                          issuetype={'name': 'Bug'})

issue.update(fields={'parent': {'id': epic.id}})
Mathieu answered 10/1, 2022 at 14:35 Comment(1)
Whenever I try to run this code, it returns that the Issue object is not subscriptable.Wristwatch

© 2022 - 2024 — McMap. All rights reserved.