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 !
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.ComponentAccessorimport com.atlassian.jira.issue.IssueManagerimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.comments.Commentimport com.atlassian.jira.issue.comments.CommentManagerString issueKey = 'TXS-561'IssueManager issueManager = ComponentAccessor.issueManagerCommentManager commentManager = ComponentAccessor.commentManagerMutableIssue 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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ;) )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.