Example scripts
To homepage
Jira

Delete Group(s) in Jira
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.11 - 8.18)

ScriptRunner For Jira (6.30.2)
Language |
groovy
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.group.search.GroupPickerSearchService
import com.atlassian.crowd.embedded.core.util.StaticCrowdServiceFactory
// List of groups that will be removed
final def myGroupList = ['group1', 'group2', 'group3']
def crowdService = StaticCrowdServiceFactory.crowdService
def groupSearch = ComponentAccessor.getComponent(GroupPickerSearchService)
def groupManager = ComponentAccessor.groupManager
for (def group : myGroupList) {
// Check whether the group exists
if (!groupManager.allGroupNames.contains(group)) {
log.warn "Group $group does not exist"
continue
}
// Check if group is not empty
if (groupManager.getUserNamesInGroup(group).size() != 0) {
log.warn "Group $group is not empty"
continue
}
// Remove the group and return the status
def removeStatus = crowdService.removeGroup(groupSearch.getGroupByName(group))
if (removeStatus) {
log.warn "Removed group $group"
}
}
Having an issue with this script?
Report it here