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}",
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.