Hi community,
I have a script which is supposed to create a log of all external comments during an event listener.
Here is my code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.issue.IssueEvent
import groovy.json.JsonSlurper
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.servicedesk.api.comment.ServiceDeskCommentService
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService
@WithPlugin('com.atlassian.servicedesk')
@PluginModule
ServiceDeskCommentService serviceDeskCommentService
final SD_PUBLIC_COMMENT = "sd.public.comment"
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def commentManager = ComponentAccessor.getCommentManager()
def event = event as IssueEvent
def issueManager = ComponentAccessor.issueManager
def issue = event.getIssue()
def comment = event.getComment()
def isInternal = { Comment c ->
def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT).getEntityProperty().getOrNull()
}
commentManager.getComments(issue).each {
if (isInternal(it) == false){
def log = Logger.getLogger("Comments")
log.setLevel(Level.DEBUG)
log.debug it.body
}
}
The problem is that no log is being created even if the script work without error.
Is there a problem with the script?
Best regards,
Jason Li