Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Copy comment from all Sub-Task to Parent and from Paren to Subtask

wojciechwoytynowski February 24, 2022

I've been looking everywhere for a script that copies comments both ways, that is, from parent to bubtask and from subtask to parent, and I finally have it :)


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser

MutableIssue issue = event?.getIssue()
CommentManager cm = ComponentAccessor.getCommentManager();
WatcherManager wm = ComponentAccessor.getWatcherManager()
ApplicationUser currentUser = event.getUser()
ApplicationUser epmjraplugin = ComponentAccessor.getUserManager().getUserByName("epmjraplugin")

if (issue.issueType.name.toUpperCase() == "STORY" || issue.issueType.name.toUpperCase() == "BUG" || issue.isSubTask()) {

if (!currentUser.equals(epmjraplugin)) {
def comment = event.getComment()

if (issue.isSubTask()) {
issue.getParentObject().each { it ->
Issue sourceIssue = it
log.error(sourceIssue)
log.error(sourceIssue.getIssueTypeId())
log.error("status źródła " + sourceIssue.getStatusId())
cm.create(sourceIssue, epmjraplugin, "Comment copied from sub-task's comment: $event.issue.key" + "\nComment added by: " + event.getUser().getDisplayName() + " \nComment content: " + comment.getBody(), true)
}
} else {
issue.getSubTaskObjects().each {
Issue sourceIssue = it
log.error(sourceIssue)
log.error(sourceIssue.getIssueTypeId())
log.error("status źródła " + sourceIssue.getStatusId())
cm.create(sourceIssue, epmjraplugin, "comment copied from main task's comment: $event.issue.key" + "\nComment added by: " + event.getUser().getDisplayName() + " \nTreść komentarza: " + comment.getBody(), true)
}
}

}
}

//"Comment from sub-task: $event.issue.key:\n{quote} $event.comment.body {quote}",

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events