User Tools

Site Tools


cleanup_comments

This is an old revision of the document!


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”

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

Reference: https://community.atlassian.com/t5/Jira-questions/Bulk-Delete-Comments/qaq-p/368877

cleanup_comments.1571679967.txt.gz · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki