I am trying to use a Listener in scriptrunner to send an email to members of an admin group (abc-admin) when a user is added to a another group (abc-users). I user Jira Data Center v. 10.x
I found this online, but I'm having to specify a specific address vs. a group as the recipient. Can anyone help me refine this and fill out the Listener creation screen?
import com.atlassian.crowd.event.group.GroupMembershipCreatedEvent
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.queue.SingleMailQueueItem
def event = event as GroupMembershipCreatedEvent
// Define the target group and recipient email address
def targetGroupName = "abc-users" // Replace with the actual group name
def recipientEmail = "abcperson@caci.com" // Replace with your email address
if (event.groupName == targetGroupName) {
def email = new Email(recipientEmail)
email.setSubject("Jira Notification: User Added to '${targetGroupName}'")
email.setBody("User '${event.entityName}' has been added to the group '${event.groupName}'.")
// email.setMimeType("text/html") // Uncomment for HTML email body if needed
SingleMailQueueItem item = new SingleMailQueueItem(email)
ComponentAccessor.getMailQueue().addItem(item)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.