I'm working on a Script Runner Listener and having problems pulling in the issue key. What am I missing?
The error is coming from the
def getIssue=issueManager.getIssue(issueNum)
package com.onresolve.jira.groovy.listeners import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import org.apache.log4j.Category class myTestListener extends AbstractIssueEventListener { Category log = Category.getInstance(myTestListener.class) //Set the logging level //log.setLevel(org.apache.log4j.Level.DEBUG) //log.setLevel(org.apache.log4j.Level.ERROR) ComponentManager componentManager = ComponentManager.getInstance() def customFieldManager = ComponentAccessor.getCustomFieldManager() def issueFactory = componentManager.getIssueFactory() def issueManager = componentManager.getIssueManager() def changeHistoryManager = ComponentAccessor.getChangeHistoryManager() @Override void workflowEvent(IssueEvent event) { Map eventTypes = ComponentManager.getInstance().getEventTypeManager().getEventTypesMap() log.debug "Event: \"${eventTypes[event.getEventTypeId()].name}\" fired for ${event.issue} and caught by myTestListener" //log.debug "Event issue ${event.issue} ${${event.issue}.getClass()}" log.debug "Event type ID - \"${eventTypes[event.getEventTypeId()]}\" fired for ${event.issue} and caught by myTestListener" if (eventTypes[event.getEventTypeId()].name == "Issue Assigned"){ log.debug "Inside if statement" log.debug "Event.Issue = $event.issue" def issueAssigneeHistory = changeHistoryManager.getChangeItemsForField(event.issue, "Assignee") log.debug "issueAssigneeHistory $issueAssigneeHistory" def issueNum = event.issue def getIssue = issueManager.getIssue(issueNum) log.debug "getIssue $getIssue " log.debug "Before nested if" if (issueAssigneeHistory.size() == 0) { log.debug ("There have been no assignees") def updateDate = event.issue.getUpdated() def assignDate = customFieldManager.getCustomFieldObjectByName("Assigned Date") def updateValue = updateDate.getValue(getIssue) log.debug "updateValue $updateValue" if(updateValue) { def timeStamp = updateValue.toTimestamp() getIssue.assignDate = timeStamp indexManager.reIndex(getIssue) getIssue.store() log.debug "Updated issue $getIssue " } } else log.debug "Issue ${event.issue} has already been assigned previously." } else log.debug "Not an Issue Assigned Event." } }
Here is the full error minus the stack. You can see at the end that the issue key is being referenced, but I've obviously missed something.
2014-12-16 16:52:08,009 http-bio-8157-exec-25 ERROR req85518 1012x606x1 1wt3vzf 10.9.96.140,10.8.172.91 /secure/IssueAction.jspa [atlassian.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event 'com.atlassian.jira.event.issue.IssueEvent@2cce2c2c[issue=CT-31,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][id,30303][author,req*****][created,2014-12-16 16:52:05.933][issue,25033],eventTypeId=3,sendMail=true,params={event=com.atlassian.jira.event.issue.IssueEvent@13b613af[issue=CT-31,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][id,30303][author,req*****][created,2014-12-16 16:52:05.932][issue,25033],eventTypeId=2,sendMail=true,params={eventsource=action, baseurl=https://webcat5.{company}.com/jira},subtasksUpdated=true], issue=CT-31, FIELD_CONDITION=changeItems.any{ it.get('field')=='assignee' }, baseurl=https://webcat5.{company}.com/jira, FIELD_EVENT_ID=3},subtasksUpdated=false]' from the invoker 'SingleParameterMethodListenerInvoker{method=public void com.onresolve.jira.groovy.listener.ScriptRunnerUberListener.workflowEvent(com.atlassian.jira.event.issue.IssueEvent), listener=com.onresolve.jira.groovy.listener.ScriptRunnerUberListener@3908bcc5}'. java.lang.RuntimeException: No signature of method: com.atlassian.jira.issue.managers.DefaultIssueManager.getIssue() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl) values: [CT-31] Possible solutions: getIssue(java.lang.Long), getIssue(java.lang.String), getIssues(java.util.Collection)
"No signature of method" means you are passing a variable into a function that does not accept the type of variable you've put in.
In this case, getIssue() is expecting a long (issue's id in the database), a string (the key of the issue), or a collection (I think that's a collection of longs or strings) representing a set of issues.
You're effectively passing in event.issue, which is an issue object, not an ID or Key.
What Nic said. You don't need to get the issue, you already have it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.