It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Nest a group via Groovy using script runner Edited

I've enabled Nested groups in jira, but now wish to nest AD groups within jira groups with groovy (via the Script Runner console).



does not work via the Script Runner console, no error message is provided

2 answers

You can do this using the following script, but you'll need to replace the group names:

import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.component.ComponentAccessor

def authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def groupService = ComponentAccessor.getComponent(GroupService)

def jiraServiceContext = new JiraServiceContextImpl(authenticationContext.getLoggedInUser())

// groups that can have groups added to them
def nestedGroups = ["nested1", "nested2"]

// the groups to add to the nested groups above as children
def childGroups = ["group1", "group2"]

def groupValidationResult = groupService.validateAddGroupsToGroup(jiraServiceContext, nestedGroups, childGroups)

if (groupValidationResult.isSuccess()) {

groupService.addGroupsToGroups(jiraServiceContext, nestedGroups, childGroups)
} else {
log.warn "invalid children groups: $groupValidationResult.invalidChildren"

 Notably this uses GroupService to add nested groups. I'd recommend using GroupService, as it performs some validation that GroupManager may not.

Thanks Adam.

This works great for Jira-originated groups but doesn't work for AD groups. Is nesting not supported for AD?

Good to hear you got it working. 

The response here indicated you may need to change some configuration to get nested groups working for AD.

Hope this helps.

Unless I'm mistaken the post you provided is to do with altering the AD integration to find users in AD sub-groups of AD groups.

I wish to nest AD groups within Jira-only groups via groovy. This is possible via the GUI (after enabling nested groups in User Mgmt).


Any ideas Adam?

Reopened. Can anyone assist?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

567 views 6 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you