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')
Copy

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')
Copy

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)
Copy

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)
Copy

Getting all members of a group

You can get group members as follows:

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

Deleting a group

You can delete a group as follows:

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



Related content

On this page