Send email notification to users in a certain group

Hi guys,

I am trying to filter some issues and send mails to the users from a group.

The thing is I could not manage to get the users from a certain group.

I used com.opensymphony.user.UserManager class but this was only for JIRA v4 and I am using JIRA v5.2.4.

Any ideea what class should I use in JIRA5?

This is what I have so far:

"<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:email="jelly:email" xmlns:log="jelly:log" xmlns:util="jelly:util">

<!-- Run the SearchRequestFilter -->

<jira:RunSearchRequest filterid="17280" var="issues" />

<!-- Iterate through the found issues -->

<core:forEach var="issue" items="${issues}">

<log:warn>Sending notifications for critical unassign issue ${issue.key}</log:warn>

<!-- Get Users from test group to send notification -->

     <core:invokeStatic className="com.opensymphony.user.UserManager" method="getInstance" var="instance"/>

         <core:invoke on="${instance}" method="getGroup" var="grp">

             <core:arg type="java.lang.String" value="test"/>

         </core:invoke>

         <core:invoke on="${grp}" method="getUsers" var="users"/>

<!-- Send notification to each user in infrastructure group -->

<core:forEach var="user" items="${users}">

<email:email server="smtp.server.com" from="jira <at> domain.com" to="${user} <at> domain.com" subject="[JIRA] Critical Unassign: ${issue.key}">

            [  https://domain.com/jira/browse/${issue.key}?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

            REMINDER: ${issue.key} with priority 0 is unassign for more than an hour   

            --------------------------------------

            ${issue.summary}

            --------------------------------------------

                 Key: ${issue.key}

                 URL: https://domain.com/jira/browse/${issue.key}

            Reporter: ${issue.reporter}

            Assignee: ${issue.assignee}

            </email:email>

</core:forEach>

</core:forEach>

</JiraJelly>

3 answers

1 accepted

This widget could not be displayed.

You need to get hold of the GroupManager. The script shown below will print the email addresses of users in the jira-users group into the log:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">
<jira:LoadManager var="groupManager" manager="GroupManager"/>

<core:invoke on="${groupManager}" method="getUsersInGroup" var="users">
<core:arg type="java.lang.String" value="jira-users"/>
</core:invoke>

<core:forEach var="user" items="${users}">
<log:warn>User = ${user.emailAddress}</log:warn>
</core:forEach>
</JiraJelly>

Thanks for this one, helped me out :)

This widget could not be displayed.

Thank you very much David , that worked perfectly

This widget could not be displayed.

how to set value of email server in email tag

How to get the current email address ?

Thanks

Gary

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

141 views 16 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you