Snippets

Adaptavist Listener that add new users to the jira-users group

You are viewing an old version of this snippet. View the current version.
Revised by Thanos Batagiannis 92c811b
/**
 * A script that listens to new UserCreatedEvents and adds the new user to the jira-users group.
 */
import com.atlassian.jira.component.ComponentAccessor

final def JIRA_GROUP = "jira-users"

def newUserName = event.user.name as String
def user = ComponentAccessor.getUserManager().getUserByName(newUserName)

def groupManager = ComponentAccessor.getGroupManager()

ComponentAccessor.getGroupManager().addUserToGroup(user, groupManager.getGroup(JIRA_GROUP))

log.debug "New user with name: ${user.displayName} and key: ${user.key} added to group: ${JIRA_GROUP}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.