How to remove epic link in python? Edited

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

This widget could not be displayed.

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. 

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 Seaver Atlassian Team Aug 01, 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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

150 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you