Hi there! with my script I want to replicate the comment entered in the destination issue when I generating a link
The code gives me an error in the following script line:
def lastcomment =event.getComment()
No signature of method: java.lang.String.getComment() is applicable for argument types: () values: []
I leave the complete code:
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.event.issue.IssueEvent
def log = Logger.getLogger("com.nolddor")
log.setLevel(Level.DEBUG)
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def commentManager = ComponentAccessor.getCommentManager()
def event = event as IssueLinkCreatedEvent
def issueLink = event.issueLink
def sourceIssue = event.issueLink.sourceObject
def destinationIssue = event.issueLink.destinationObject
def lastcomment =event.getComment()
def comments = ComponentAccessor.commentManager.getComments(sourceIssue)
String lclc = comments.body.last()
log.debug(lclc)
//def commentAuthor = comments.getAuthorApplicationUser()
if (comments) {
//commentManager.create(destinationIssue, loggedInUser, "sdf", true)
def autor= comments.last().getAuthorApplicationUser()
log.warn(autor)
//commentManager.addCommentToObject()
//commentManager.create(destinationIssue, comments.authorApplicationUser, comments.body, true);
commentManager.create(issueLink.getDestinationObject(), autor, lclc, true)
}
log.debug "An IssueLinkCreate event has been catched"
log.debug "Issue (from): ${sourceIssue.key}"
log.debug "Issue (to): ${destinationIssue.key}"