Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to use python for bulk link removal on jira?

Ahsan Ahmed
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 30, 2018

Can somebody please share a sample of python script on how to perform bulk removal of links in Jira. 

1 answer

2 votes
Mauricio Karas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 13, 2018

Hello there, Ahsan!

If you're talking about removing issue links, you can use the following Python script that uses the "requests" library.

import requests

base_url = "<base_url>"

delete_link = "/rest/api/2/issueLink/{0}"

jql = "project=<project_name>" # You can use any jql you want to get the issues.
jql_search_issues = "/rest/api/2/search?jql={0}".format(jql)

issues = requests.get(base_url+jql_search_issues, auth=('user', 'pass')).json()

issue_links = [[link['id'] for link in issue['fields']['issuelinks']] for issue in issues['issues']]

for links in issue_links:
if len(links) != 0:
for link_id in links:
delete = requests.delete(base_url+delete_link.format(link_id), auth=('user', 'pass'))
print(delete.status_code, delete.content)

The script gets a list of issues based on a JQL, then it deletes all issue links from those issues.

Let me know if you have any questions.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events