How to remove epic link in python?

Sam Morrison June 19, 2017

I am trying to use the Jira Python API to automatically add and remove issues. When adding, I was able to assign the epic link field (customfield_1006) to the name of an existing epic link, but when I try to remove the epic link by assigning it to an empty string, Jira throws an internal server error. I can remove the epic link through my browser, but I can't automate it through Python. Is there any way to remove an issue from an epic link using the API?

1 answer

1 accepted

0 votes
Answer accepted
Shaun S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 31, 2017

I wasn't able to remove an epic link from an issue with the existing JIRA Python library. I was able to write this definition and add it to the client.py file to add this functionality.
I added this to client.py

 def remove_from_epic(self, issue_keys): 
if self._options['agile_rest_path'] != GreenHopperResource.GREENHOPPER_REST_PATH:
raise NotImplementedError('JIRA Agile Public API does not support this request')

data = {}
data['issueKeys'] = issue_keys
url = self._get_url('epics/remove', base=self.AGILE_BASE_URL)
return self._session.put(
url, data=json.dumps(data))

You can then remove the epic link from an issue in your code with the line below.  

jira=JIRA
jira.remove_from_epic(issue_keys=['<issue_key'])

 

I created a pull request to add this code to the repo so hopefully it will be integrated into a future release. 

Sam Morrison August 1, 2017

Hi Shaun,

Thank you so much for implementing this fix! Will it be available in a library I can import soon? If I need to copy the script you wrote into my code instead, is there a library I need to import in order to make this function (besides JIRA)? 

Shaun S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 1, 2017

Sam,

 

No problem! I added the remove_from_epic definition to the client.py file for jira-python.  For me this path is 

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jira/client.py

Depending on what OS and version of Python you're using, this path may be different. As far as when it will be available I'm not sure. I submitted a pull request yesterday, and the code is still under review. You can view the progress here. I forgot to mention that this also accepts multiple issue-keys to remove the epic link from. 

Suggest an answer

Log in or Sign up to answer