Hi Team,
I want to copy the public comments only between the linked issues. I have written a script to copy all the comments but how to just copy the comments only when they are made public.
Also i a getting a syntax error in the script , please find the below code, could you please suggest what is wrong in the script also what changes needs to be made in order to only copy the public comments.
Error Message - "The variable [event] is undeclared", pfa screen shot for the same.
SCRIPT STARTED -
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.component.ComponentAccessor;
def event = event as IssueEvent
def comment = event.getComment()
def issue = event.getIssue()
CommentManager commentManager = ComponentAccessor.getCommentManager()
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String commentBody = comment.getBody()
issueLinkManager.getOutwardLinks(issue.getId()).each {IssueLink issueLink ->
commentManager.create(issueLink.getDestinationObject(), loggedInUser, commentBody, false)
}
issueLinkManager.getInwardLinks(issue.getId()).each {IssueLink issueLink ->
commentManager.create(issueLink.getSourceObject(), loggedInUser, commentBody, false)
}
SCRIPT End