Hello,
I'd like to set up a Scriptrunner Custom Scheduled Job to send a Custom Event once per day. This custom event would then be picked up by a Listener (for issue events) and fire off a custom email rounding up some key information.
I realize that I can also generate emails directly from a Custom Job, but the Listener interface is much easier for generating a complex HTML template with in-line database queries.
I have the following code, which seems to fire the event off just fine:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEventBundleFactory
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.IssueEventBundle
import com.atlassian.jira.issue.Issue
IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager()
IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class)
def userManager = ComponentAccessor.getUserManager();
def automationUser = userManager.getUserByName("user_name");
Issue issue
int EVENT_ID = 10100
IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(new IssueEvent (issue, null, automationUser, (Long)EVENT_ID, true))
issueEventM.dispatchEvent(eventBundle)
However the Listener errors out and I am not sure why. Possibly the dummy issue and dummy user used to dispatch the event? The listener currently has no code in it, just an HTML template that triggers on Event 10100.
Here is part of the Listener log:
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70) at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) at com.sun.proxy.$Proxy7043.execute(Unknown Source)
For what it's worth, in my Jira 9.5.1 DC instance, this code worked just fine.
My listener is quite involved.
It works with a 'stock' 'Generic Event' (13l for me) as well as a custom event (10202l).
I'm not using a dedicated user, but just the 'loggedInUser'.
So your suspicion towards the 'dummy-user' might just be well deserved ...
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.