Work with Groups

With HAPI we've made it easy for you to create, modify, and delete groups. 

Creating a new group

You can create a new group as follows:

            Groups.create('jira-admin')

Retrieving a group by name

You can retrieve a group by its name. You will need to retrieve a group when you wish to perform a change, for example, add or remove a user (as described in the following sections). You can retrieve a group as follows:

            Groups.getByName('jira-developers')

Adding and removing users from a group

Add a user to a group

You can add users to a group as follows:

            def group = Groups.getByName('jira-developers')
            // user can be added to the group by username
            group.add('bob')
            
            // or using an ApplicationUser instance
            def user = Users.getByName('joe')
            group.add(user)

Remove a user from a group

You can remove users as follows:

            def group = Groups.getByName('jira-developers')
            // user can be removed from the group by username
            group.remove('bob')
            
            // or using an ApplicationUser instance
            def user = Users.getByName('joe')
            group.remove(user)

Getting all members of a group

You can get group members as follows:

            def group = Groups.getByName('jira-developers')
            group.getMembers()

Deleting a group

You can delete a group as follows:

            def group = Groups.getByName('jira-developers')
            group.delete()



Related content

On this page