Hello,
Im currently working on a project to transition an issue on comment using script listener "fire generic even" but i cant seem to get the following code working.
I've selected the events "Issue Commented" and placed the following code:
package com.netic.listener
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.util.JiraUtils;
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
class ExampleListener extends AbstractIssueEventListener {
ComponentManager componentManager = ComponentManager.getInstance();
def issueLinkManager = ComponentAccessor.getIssueLinkManager();
def authContext = componentManager.getJiraAuthenticationContext()
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
@Override
void workflowEvent(IssueEvent event) {
String issueid = event.issue.id
String issuekey = event.issue.key
String status = event.issue.getStatusObject().getName()
String eventid = event.getEventTypeId()
String issuetype = event.issue.issueTypeObject.name
String currentuser = event.getUser()
currentuser = currentuser.split(":")[0]
Integer transition = 0
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " action=StartScript")
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " currentUser=" + currentuser)
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " eventid=" + eventid)
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " issuetype=" + issuetype)
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " status=" + status)
if (issuetype == "Escalation")
{
if (status == "Response") // Email Sent
{
transition == "Resolve" // Resolve
}
}
if (transition != 0 )
{
// Transist Issue
workflowTransitionUtil.setIssue(event.issue);
workflowTransitionUtil.setUsername(currentuser);
workflowTransitionUtil.setAction (transition)
// Validate and transition issue
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
status = event.issue.getStatusObject().getName()
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " Issue " + issueid + " transited to new status: " + status)
}
System.out.println("script=Listener.groovy IssueKey=" + issuekey + " action=EndScript")
}
}and place event as "Generic Event", but it doesnt seem to work, when attempting to comment, the comment section just load.
Hopefully someone can debug this would be a massive help.
Many thanks,
Pon