Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Give a Jira group application access

alex.hendry August 2, 2022

Hi all,

I am writing a script to create and manage groups in Jira Server. I can create a group:

ComponentAccessor.groupManager.createGroup(groupName)

However, I need to be able to give a group application access after I create it. How can I do this?

Thanks!

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Peter-Dave Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2022

I've never tried ... but looking through the javadocs, I found "ApplicationRoleAdminService"

So playing around with it... I was able to get it to work with these few lines of code:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.jira.application.ApplicationRoleAdminService
import com.atlassian.jira.application.ApplicationKeys

@PluginModule ApplicationRoleAdminService applicationRoleAdminService

def groupToAdd = ComponentAccessor.groupManager.getGroup('NameOFGroupToAdd')

def role = applicationRoleAdminService.getRole(ApplicationKeys.SOFTWARE ).get()
def defaultGroups = role.defaultGroups
def currentGroups = role.groups
def newGroupList = currentGroups + groupToAdd
def newRole = role.withGroups(newGroupList, defaultGroups)

applicationRoleAdminService.setRole(newRole)

Change the ApplicationKeys.SOFTWARE to any one of those listed here

alex.hendry August 3, 2022

Hi Peter-Dave,

That works perfectly. Thanks for taking the time to reply. Have a great day.

0 votes
Dennis Grochowski August 2, 2022

What exactly do you mean by "application access"?

Should the group have the license assigned like "jira-users" or would you like to add the group to a project role?

alex.hendry August 3, 2022

Hi there,

Yes, should have the licence assigned like jira-users. Manually I would go to admin -> applications - > application access then select the group using the drop-down and add it to the application.

Thanks!

TAGS
AUG Leaders

Atlassian Community Events