Work with Groups
With HAPI we've made it easy for you to with groups.
Retrieve 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:
groovyGroups.getByName('jira-developers')
Retrieve a group ID
You can retrieve a group ID, using the getByName
function.
groovyGroups.getByName('jira-developers').getGroupId()
Add users to a group
You can add users to a group as follows:
groovydef group = Groups.getByName('jira-developers') // user can be added to the group by their account id group.add('user_account_id')
Get all members of a group
You can get group members as follows:
groovydef group = Groups.getByName('jira-developers') group.getMembers()
Check if a group contains users
You can check if a group contains a user of your choice as follows:
groovyGroups.getByName('jira-developers').contains('user_account_id')