Forums

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

Scriptrunner script to email jira-group members when a user added to a specific group in jira

Kathy Dickason
Contributor
August 13, 2025

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)

    }

1 answer

0 votes
Matt Doar
Contributor
August 13, 2025

Is the problem that a Jira group is a collection of users, and you want to send email to each of the users. Or that you want an API to send email to a group? Which line of your example is not working?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events