You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi all,
I'm trying to setup a scriptrunner listener that is linked to two types of issue events:
- Issue delete
- Issue move
When the event is caught, I want to send a notification in slack.
Problem is, I don't know how to distinguish between the two events within the same listener.
So far I had to split the listener and create one linked to delete event, and another one linked to move event. Both use an event of type "IssueEvent"
import com.onresolve.scriptrunner.slack.SlackUtil
import com.atlassian.jira.event.issue.IssueEvent
// what else should I import?
def myEventClassName = event.class
def myEntityName
def myEvent
def messageHeader1 = "<!here> *ISSUE DELETED WARNING:*\n"
def messageHeader2 = "<!here> *ISSUE MOVED WARNING:*\n"
def messageHeader
if(event instanceof IssueEvent){ // this where I need to catch the delete event
messageHeader = messageHeader1
myEvent = event as IssueEvent
myEntityName = myEvent.getIssue().getKey()
} else { // this where I need to catch the move event
messageHeader = messageHeader2
// blah blah
}
SlackUtil.message(
"my_slack_connector",
"my_slack_notification_channel",
messageHeader+"\n"+myEventClassName+": "+myEntityName,
[
username: "My bot",
icon_emoji : ":myavatar"
]
)
You can use this to catch the event type:
As I found you have to set the listener to global or you have to define all the project the issues can be moved to. I found that if I just set the listener to one project and I move the issue to another one, you won't catch the issue moved event, only if the listener is global or the target project is included either.
Hope this helps!
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.