It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

bulk delete all spam comments of a given user (then the user itself)

Martin Jul 28, 2014

Hi,

We have an user that is posting spam comment in some of our projects. We would like to delete all its comments (we don't want these to appear). How is it possible to do this in bulk ?

When this required step is achieved we will be able to delete the user completely.

Thanks !

1 answer

1 vote
Anna Cardino Atlassian Team Jul 28, 2014

Hi Martin,

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).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 ->
if (comment.body.contains('Bla Bla Bla')) {
commentManager.delete(comment)
}
}

Hope it helps.

Monique

Anna Cardino Atlassian Team Jul 28, 2014

For further details, you may refer to this link which looks similar to your query.

https://answers.atlassian.com/questions/194260/bulk-delete-comments

Monique

Martin Jul 28, 2014

Hi Monique and thank you. This script is based on comment body criteria, not on comment author. ( And it is also based on a particular issue, where I want it (at least) based on project ;) )

JamieA Jul 28, 2014

You can use the jql function: commented, eg issueFunction in commented("by eviluser"), and feed the list of issues into the script Monique posted.

Filter on comment.author rather than comment.body

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,020 views 13 15
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you