Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi Team,
How can i delete bulk component in jira?
I have 1000 + component and i want to delete most of it,
so deleting one by one would be cumbersome.
Is there a easy way to delete multiple component?
oh, I don't want just clearing a component field in issue.
I do really want delete it from project.
thanks.
If anyone else hits this problem, here is a Python 2.7 script you can use, replacing <base-url> and <project> accordingly for your environment. It requires requests be installed, but should be pretty easy to use.
import requests
import json
import getpass
# Username and password terminal input
username = raw_input('Jira Username: ')
password = getpass.getpass()
# Initiate session with requests.
s = requests.Session()
# Make initial request to grab a list of all <project> components.
r = s.get(
url='https://<base-url>/rest/api/2/project/<project>/components',
auth=(username, password),
headers={'Content-Type': 'application/json'}
)
full_list = r.json()
id_list = []
# Pull all components, and add their IDs to a list (id_list).
for comp in full_list:
id_list.append(comp.get('id'))
# Confirm that you want to run the update.
conf_resp = raw_input('This will update ' + str(len(id_list)) + ' components. Proceed? (y/n): ')
# Using that list, delete the component.
if conf_resp == 'y':
for id in id_list:
id_fix = s.delete(
url='https:///<base-url>/rest/api/2/component/' + id
)
else:
print 'Component update aborted.'
Hi All (past and, more importantly, FUTURE!),
I too came across this dilemma when trying to mass archive components. Apparently there is no way to do this via REST API. But there is a way to do it via UI. I didn't want to click archive on each button since we had 90+ components. After thinking a bit, I found that I can command my browser to do it.
Turns out all the Archive links in the "..." menu are all assigned to a class. So in CHROME use the querySelectorAll to grab them, then issue a click for each one!
acomp = document.querySelectorAll(".archivecomponent_link");
for (var i=0; i<acomp.length; i++){
console.log(acomp[i].id); acomp[i].click();}
The DELETE button is a little trickier as it pops up a dialog box, but I assume it can also be automated, maybe wait 1 second for load, then query for Submit button and issue a "click()" on it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think that there is a way to delete components using the REST API.
https://docs.atlassian.com/software/jira/docs/api/REST/7.13.8/#api/2/component-delete
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
underrated anwser
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did it via bash
API_USER={your username}
API_KEY={your API key}
API_URL=https://{your domain}.atlassian.net/rest/api/2
while IFS= read -r id
do
curl -s -X "DELETE" -u $API_USER:$API_KEY $API_URL/component/$id
echo "Deleted component $id"
done < <(curl -s -u $API_USER:$API_KEY $API_URL/project/DOM/components \
| jq -r '.[] .id')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @HyunSung Jang ,
I'm aware I'm posting really late, but this may be helpful to others who are facing the same problem.
One great alternative to bulk delete components without any coding or back-end work is by using Profields' Bulk Operations. You can see the documentation here, it does exactly what you were looking for.
The selection of the projects to be deleted can be done with simple searches or advanced queries in Profields' Project Navigator.
Hope this was helpful!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
If you want an out of the box solution, you can use the Jira Rest Api:
1. Get all components by
2. Delete components by
https://docs.atlassian.com/software/jira/docs/api/REST/7.12.0/#api/2/component-delete
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for your advice
If I delete component from database directly, is it will causing any problem?
I'm considering execute sql query like this..
"delete from jiradb.component where cname like 'test%'"
this query shows me, delete over 500 rows..
I'm not confident to execute it is safe or not.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It will make your data in the database inconsistent. You will delete just components, but all references to this components from issues will stay. I would advise not to do it via SQL quieries.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes.. you are right..
many issues will loose its component referencing if I delete component via SQL.
I don't care about it for now, but will reconsidering it
thank you for your help !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexey Matveev,I would like to ask you a question relevant to@HyunSung Jang previous!!! I know that it is the worst thing to touch the database!
Considering that he has 1000+ components.. Could it be faster to check with an SQL query which components have no issues and then use the Jira Rest Api ???
So i am thinking about a script with a JQL and then a loop to delete these components. Is my though right?
Forgive me if my thought is wrong but i am new to the script world :D
Best regards
CM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To tell you the truth I have a rule never to do any inserts or updates in the Jira database. I always use Jira Api to change anything in Jira.
I think it is feasible the way you want to do it. But you never know what can go wrong because it is not the right way to do. Everything must be done through Jira Api. Anyway test your solution first in QA and make a backup.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexey Matveev thank you a lot for your advice!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Christos Moysiadis You are welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.