This shows you the differences between two versions of the page.
— |
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 = ' | ||
+ | |||
+ | IssueManager issueManager = ComponentAccessor.issueManager | ||
+ | CommentManager commentManager = ComponentAccessor.commentManager | ||
+ | |||
+ | MutableIssue issue = issueManager.getIssueObject(issueKey) | ||
+ | List< | ||
+ | comments.each {comment ->; | ||
+ | if (comment.body.contains(' | ||
+ | commentManager.delete(comment) | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Reference: https:// |