How to delete all project issues efficiently?

Balint Nagy August 26, 2016

Hi,

I have to migrate tasks from another system to Jira, approximately 17000. When testing the migration, it's really painful to clean up, as bulk operations are limited to 1000 at a time. I had that raised to 10000, but bulk operations failed for such an amount. We lowered it to 5000, and lived with that for a while, but then Jira started to fail for 4000, than for 3000, then for 2000 at a time...

I'd need a solution that

a.) Quickly deletes all issues from a Jira project (I don't mind if issue numbering is reset or is continued).

b.) Have the bulk operation run for as many issues as possible at a time. (this is the less preferred solution as it is really slow, but I can live with that)

I'd rather not delete the project itself, as it has a bunch of configuration applied to it (workflow, screen, issue schemes, etc.).

Any ideas?

6 answers

1 vote
Bob Swift _Appfire_ August 30, 2016

Use JIRA Command Line Interface (CLI) and something like:

--action runFromIssueList --jql "project = XXX order by key desc" --common "--action deleteIssue --issue @issue@"
Balint Nagy September 6, 2016

I tried

    jira --action runFromIssueList --jql "project = ProjName order by key desc" --common "--action deleteIssue --issue @issue@"

but received this:

Error: Parameter 'action' cannot be declared more than once.
Error: Parameter 'jql' cannot be declared more than once.
Error: Parameter 'common' cannot be declared more than once.

Balint Nagy September 7, 2016

I also found examples here: https://bobswift.atlassian.net/wiki/display/JCLI/Examples

so I tried

    jira --action runFromIssueList --common "--action deleteIssue --issue @issue@" --search 'project = "ProjName"'

that resulted in 

    Error: Unexpected argument: =
    Error: Unexpected argument: ProjName'
    Error: Parameter 'action' cannot be declared more than once.
    Error: Parameter 'common' cannot be declared more than once.
    Error: Parameter 'search' cannot be declared more than once.
    Error: Unexpected argument: =
    Error: Unexpected argument: ProjName'

So it seems to me that the examples simply don't work... sad

My java version is

C:\Jira>java -version
java version "1.8.0_101"

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2016

The examples do work. Is that the exact action string you are using with ProjName? I suspect not. Make sure you have not double quoted it. Embedded double quotes need to be escaped. I recommend using project key so quotes are not needed in your JQL. And for other cases, always use single quotes in your JQL so you don't have to worry about escaping double quotes.

Balint Nagy September 7, 2016

Sorry for the delayed answer, the system prevented me from posting too many comments...

The issue was that I incorrectly customized the jira.bat file, putting %* twice in the command line.

The script (and the examples smile) work fine now.

Thanks!

1 vote
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 26, 2016

Balint,

If you delete the project then its configurations will not be deleted. To be on safer side keep a copy of it's configurations.

Otherwise you can use JIRA Rest API to delete the issues in bulk. What I do is use a label like "bulk-26Aug16", in case bulk import fails I can quickly find these issues wither by JQL and then delete it either through the UI or REST API.

-Ravi

MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2016

Delete rather than import, I think you meant.

haim azar April 26, 2019

how do you do bulk delete with REST API

Like Sergiu Ciupe likes this
0 votes
Balint Nagy September 8, 2016

Yes, any script is OK. The one I got to use is Bob Swift CLI.

0 votes
stratejos [stratejos.ai] September 8, 2016

when you say "babysit the deletion process" - does writing a script that uses the REST API meet this requirement?

0 votes
Balint Nagy September 7, 2016

Having seen the comments I have to add what I meant by efficiency was that I don't have to babysit the deletion process. I don't mind if it runs slow, as long as it runs without user interaction.

JIRA Command Line Interface, although I have not yet decided whether to buy it.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 26, 2016

You could script it, but it's not going to be faster than bulk-delete.

The easiest way really is "delete project", as that will just churn through all the issues, there's no limit on the number in the project.  If you do delete a project, then there's some points to remember:

  • Deleting a project does NOT delete the schemes, even if they were only for that project.  You could take a screenshot of the schemes the project uses, delete it and then create a new project and tell it to use the old schemes
  • You can NOT reuse a project key, unless you're willing to do database hacks (you can't delete project ABC and then create another one with key ABC)
  • If you do delete projects, as I said, the schemes will be in place, but you will have to check all your custom field contexts.  If they're all global, or done by issue-type, that'll be fine, but if you have a field that had a context of "only show in projects ABC, DEF and GHI", then deleting project ABC will remove that and you'll need to re-add it.
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 26, 2016

Good points!

MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2016

I tend to go with a jira-python script to search for the issues and then delete them one by one. Not very fast, but you can restart it and it doesn't timeout

Suggest an answer

Log in or Sign up to answer