Skip to content

Instantly share code, notes, and snippets.

@jfut
Created May 6, 2015 07:48
Show Gist options
  • Save jfut/e5c96318ea2a680dcca6 to your computer and use it in GitHub Desktop.
Save jfut/e5c96318ea2a680dcca6 to your computer and use it in GitHub Desktop.
JIRA: Delete spam comments script
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 = 'CHURA-XX'
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('spam words')) {
commentManager.delete(comment)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment