Hi,
is there a simple way to fire an issue event using Script Runner Escalation Service by giving event's ID? I only managed to find some old examples with deprecated methods that can't be used in latest versions of JIRA and Script Runner.
In my case I just want to fire one of the defined events to catch it by listener so I can send a custom e-mail to some reporters.
I suspect I should use something like EventPublisher.publish(some_event) but how to assign some_event variable with existing event's ID?
An example would be much appreciated.
Community moderators have prevented the ability to post new answers.
Finally I've used following code. Maybe someone finds it useful in the future.
import com.atlassian.jira.event.issue.IssueEventBundle import com.atlassian.jira.event.issue.IssueEventManager import com.atlassian.jira.event.issue.IssueEventBundleFactory import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.issue.IssueEvent Long EVENT_ID = new Long("10500") def issueManager = ComponentAccessor.getIssueManager() def user = ComponentAccessor.getUserManager().getUserByName('user_worker') IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager() IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class) IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(new IssueEvent (issue, null, user, EVENT_ID, true)) issueEventM.dispatchEvent(eventBundle)
Well, I sure did !
I couldn't find any proper implementation of the EventBundle thing. Thanks a lot for this code, I got my events working fine again.
And thumbs up for all people who post their code once they found a solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried using your code but I got an error:
Error
Could not find matching constructor for: com.atlassian.jira.event.issue.IssueEvent(com.atlassian.jira.issue.IssueImpl, null, com.atlassian.jira.user.DelegatingApplicationUser, java.lang.Long, java.lang.Boolean)
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.atlassian.jira.event.issue.IssueEvent(com.atlassian.jira.issue.IssueImpl, null, com.atlassian.jira.user.DelegatingApplicationUser, java.lang.Long, java.lang.Boolean)
at Script181.run(Script181.groovy:14)
Looks like it doesn't like this line:
IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(
new
IssueEvent (issue,
null
, user, EVENT_ID, true))
any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This script still works without any problems in our instance. Make sure that you haven't missed any part of the script... or maybe you are using some old version of Script Runner and/or Jira. We are currently running Script Runner 4.3.15 and JIRA 7.2.1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My guess is that it is because we are on JIRA 6.4.11 and 6.4 doesnt support that method... any idea how to make it backwards compatible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, but I'm not that advanced in groovy. For me it seems that all the necessary elements are available in 6.4:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Adam White I don't know if you figured it out but for JIRA 6.4.1 API, make sure that the parameters you pass matches the class constructor signature.
https://docs.atlassian.com/jira/6.4.1/com/atlassian/jira/event/issue/IssueEvent.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adam,
My client wants to set a reminder for reporters to close resolved issues, once a day until they finally close those issues. So the escalation firing an event that is later caught by listener to send a custom e-mail seems like a good option.
I wanted to use Jira Automation plugin to fire an event, but it cannot fire an event properly (at least such an event couldn't be processed by listener because it lacks some parameters).
I want to use events to avoid updating the issue in the history but I just realized that it might be a wrong assumption. Can I successfully fire an event without updating an issue? I mean without changing "updated date"?
Regards,
Bartek
P.S. I tried to use your suggestion and wrote something like this:
import com.atlassian.event.api.EventPublisher import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.component.ComponentAccessor def user = ComponentAccessor.getUserManager().getUserByName('bzukowski') EventPublisher.publish(new IssueEvent(issue,user,null,null,null,null,10500))
but it doesn't seem to be working and I am only getting:
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.event.api.EventPublisher.publish() is applicable for argument types: (com.atlassian.jira.event.issue.IssueEvent) values: [com.atlassian.jira.event.issue.IssueEvent@65039afe[issue=ZUKU-1,comment=<null>,worklog=<null>,changelog=<null>,eventTypeId=10500,sendMail=true,params={},subtasksUpdated=false]] at Script281.run(Script281.groovy:7)
Probably it's something obvious but not for me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you want to send an email every time the escalation service is run or only when an issue has been updated via the escalation service? Sure you can use:
eventPublisher.publish(new IssueEvent(...));
But i'm not sure if this is a good solution to your problem.
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.