User Tools

Site Tools


cleanup_comments

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cleanup_comments [2019/10/21 13:46] (current)
root created
Line 1: Line 1:
 +===== Cleanup Comments =====
  
 +This script allows to delete comments with specific text in the content of the comment, in this particular case in ticket ABC-123 any comment containing "bla bla bla"
 +
 +<code java>
 +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 = 'ABC-123'
 +
 +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)
 +    }
 +}
 +</code>
 +
 +Reference: https://community.atlassian.com/t5/Jira-questions/Bulk-Delete-Comments/qaq-p/368877
cleanup_comments.txt ยท Last modified: 2019/10/21 13:46 by root