Customize Templates based on recipient group membership

Scenario

You want your templates to be different depending on whether a recipient of the notification is a member of a particular JIRA group.

Configuration

The following velocity script allows one template to be sent if a user is a member of a specified group, and another if they are not.  It is recommended to have this set up in a macro, which you can then call.  This makes maintenance of the script easier and less time consuming.

This script could be adapted to allow multiple groups to have different templates for an event.

#if($groupManager.getGroupNamesForUser($recipientUser).contains("jira-administrators")) Hello admin!<br/> #else Hello non-admin!<br/> #end