Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to throw a custom issue event from a post function script (Jira 7) ?

DupontD February 4, 2016

Hello,

 

I want to throw a custom event from a post function with a groovy / script runner script in a JIRA 7 platform.

For example :

If customfield xxx has value A -> throw custom event A (to notify group A)

if customfield xxx has value B -> throw custom event B (to notify group B)

...

 

I want to use the IssueEventManager :

https://docs.atlassian.com/jira/latest/com/atlassian/jira/event/issue/IssueEventManager.html

 

The old method was simple but is deprecated since 6.4.10 :

dispatchEvent(Long eventTypeId, Issue issue, ApplicationUser remoteUser, boolean sendMail)

 

Now the only way is to use :

dispatchEvent(IssueEventBundle issueEventBundle)

 

How can i create a IssueEventBundle object ?

Maybe someone has an example with this new method ?

 

Thanks

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
DupontD February 4, 2016

I tried :

  • Create custom events (create issue template)
  • Add them to the notification scheme
  • Use this script (post function create transition in my case) :

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.issue.IssueEventBundle
import com.atlassian.jira.security.JiraAuthenticationContext
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("10000")
ApplicationUser currentUser
IssueEventBundle eventBundle

JiraAuthenticationContext jiraAuthContext = ComponentAccessor.getJiraAuthenticationContext()
IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager()
IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class)

currentUser = jiraAuthContext.getUser()
eventBundle = issueEventFactory.wrapInBundle(new IssueEvent (issue, null, currentUser, EVENT_ID, true))
issueEventM.dispatchEvent(eventBundle)

It seems ok (for the part "throw custom event").

0 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2016

Hi Dupont,

Maybe this older AA may give you a hint How to Throw a Custom Issue Event from a Custom Listener (it makes use of the issueEventBundle)

TAGS
AUG Leaders

Atlassian Community Events