Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Publish an event in Groovy Script

Deleted user May 24, 2018

Hello,

I want to trigger one of my Script Listener programatically in the Script Console.

I think I have to "publish an event".

my research brings me to the class EventPublisher, but I don't understand how to use it...

With this class I should be able to publish an "Issue Updated" event on some Issue.

Has anyone ever tried ?

1 answer

0 votes
Neta Elyakim
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.
May 24, 2018

What you mean by "publish an event" if you want the script to run on issue update event then run the script on issue update event.

Deleted user May 24, 2018

Excuse me I forgot to say that I want to trigger a Listener (activated with event "Issue Updated") programatically in the Script Console.

Neta Elyakim
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.
May 24, 2018

I don't think it's possible, try to get a specific issue and run the script on it from the Console:

Add this to your code-

def issue = ComponentAccessor.getIssueManager().getIssueObject("TS-93221")
Deleted user May 24, 2018

I already use this technique to test my Listener, but what I would like is more complex...

 

I try to copy som field from an Issue to an other Issue, both of them in differents Projects and differents issueTypes.

I have a field in the target Issue like "Name of source Issue", the name who's inside is like an id in a BDD.

Example :

Source Issue with Summary = "A"

some Target Issue with Summary = "B" and field "Name of source Issue" = "A"

This Issues are linked.

 

My Listener copy some field from Source to Target when the Source is updated.

For example :

I have a field "Category" in both Issues, and when I update the field in the Source Issue like "Category" = "123", my Listener is fired and it's update the field in the Target Issue !

 

Well, this works fine, but... I want to add a new Issue in the chain !

new Target Issue with Summary = "C" and field "Name of source Issue" = "B" (remember, "B" it's our first Target)

So basically, my field "Category" it's copied in cascade :

Issue "A" -> Issue "B" -> Issue "C"

 

The problem is, my Listener can't copy from "B" to "C" when is fired on the "A" update...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events