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.
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.