Bulk-Delete Comments


we had a buggy Jelly-Script which postet ten-thousands of comments on some issues.

Deleting them manually is not possible, every reload of the issue takes a few minutes.

The last chance i see is deleting them by a direct database-delete-statement.

Did anyone delete comments like this before or does anyone know if there are dependencies? or has anyone a jelly-script which is able to delete comments through api?

thanks & regards

9 answers

1 accepted

This widget could not be displayed.

Deleting directly from the database is not recommended. But you can use the Script Runner plugin and the following script to delete all comments containing a specific text (in this case "Bla Bla Bla") in a specific issue (here TXS-561).

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager

String issueKey = 'TXS-561'

IssueManager issueManager = ComponentAccessor.issueManager
CommentManager commentManager = ComponentAccessor.commentManager

MutableIssue issue = issueManager.getIssueObject(issueKey)
List<Comment> comments = commentManager.getComments(issue)
comments.each {comment -&gt;
    if (comment.body.contains('Bla Bla Bla')) {



Just wanted to say this worked like a charm for a comment spam issue I had. Thanks!

Thx for your script... I have many issue with the same comment and I will delete this comment. How can I include alle issue keys in this script?I will bulk delete this Comment?

Henning Tietgens Community Champion May 19, 2014

Take a look here on how to do a jql search. And than search for all issues and loop through the result.

Ok, but I can't include the issue keys in your script? for example

String issueKey = 'xxx-685'; String issueKey = 'xxx-686' etc...

or with another separator?

Henning Tietgens Community Champion May 19, 2014

Yes, you can.

def issueKeys = ['xxx-456', 'aaa-333']

issueKeys.each{ issueKey ->

MutableIssue ...


THX... it works fine :-)

Thanks alot for this post @Henning Tietgens. This saved me a lot of work when cleaning-up the comments some spambot left on our JIRA instance over the weekend. I also took the time to write a quick How-To to apply your script to the JIRA instance: http://www.luke1410.de/blog/?p=29

Hi @Henning Tietgens. I am on JIRA cloud and this script is giving me [x] errors to the left of all the imports at the top of your code before I even run it. The errors state "unable to resolve class com.atlassian.jira...(issue or component)" at each line (1-5). Am I missing something between the date of this post and now (a few years)?


Hi Daniel,

this is a restriction of JIRA Cloud plugins. See ScriptRunner package import restrictions

On JIRA Cloud the plugin (and therefore your script) is not able to directly interact with the JIRA system (see Script Runner Migration Guide for details), instead the REST API has to be used.

It should be possible to use https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/comment to accomplish the same thing as my script above, but I don't have a script ready for you.


This widget could not be displayed.

Or clone the issue as cloning does not clone the comments. Then delete the original issue.

the change history gets lost...

This widget could not be displayed.

Your options are very limited here. To avoid loss of history and data, you're basically down to two options

- What Henning said - even the Jira CLI and Jelly can't delete the comments, the script runner pretty much is the only approach

- As you said, hack the database. You will need to stop Jira, get a backup, remove lines from "jiraaction table", start Jira and then update the affected issues index (either with a global index, or a bulk edit or comment on the ones you've changed).

I've had a similar problem in the past, and it is moderately safe as long as you do NOTHING else. But I never recommend database hacking, because it's so easy to get it wrong.

This widget could not be displayed.

It is not easy to put everything together, but with a little groovy scripting and JIRA Command Line Interface you could probably do it.

  1. getIssueList with JQL to find the issues affected - produces a CSV that has the issue's numeric id
  2. getCommentList for each issue affected - produces a CSV of comments that has the comment's numeric id
  3. renderRequest to delete the comment similar to this example
--action renderRequest --request "/secure/DeleteComment.jspa?id=108212&amp;commentId=48026&amp;Delete=Delete"

An easier alternative is available if you are really good at SQL against the JIRA database (and NOT OnDemand) to construct the right renderRequest (like above) for all the comments you need to remove. Then just use runFromSql to run all of them.

This widget could not be displayed.

As a simple administrator, without access to scripts etc, how do I delete all comments from a page?

I've already copied page to retain snapshot with current comments.

Confluence 5.3

This is a question about JIRA. You are asking about Confluence ... just create a new question so the answers will be for Confluence.

This widget could not be displayed.

I wrote a Jira Script Runner plugin Groovy script to delete Jira comment spam entered by a spambot that uses a username "Patrickmorton". See https://gist.github.com/lhotari/caafb4d394412f491861for the source.

This is for Confluence.. not for Jira.. ;)

This widget could not be displayed.

You can use the Chrome developer tools to run JavaScript to access the JIRA API. More details are available here:


This widget could not be displayed.

I created a python script to remove all comments for a specific Jira issue. 
It uses the API from Jira. Found it the easiest way without a plugin.

Here you go:

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

72 views 1 0
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