Skip to main content
Skip table of contents

List Structure Names and Permissions

GROOVY
import com.almworks.jira.structure.api.StructureComponents
import com.almworks.jira.structure.api.forest.ForestSpec
import com.almworks.jira.structure.api.permissions.PermissionLevel
import com.almworks.jira.structure.util.Util
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin('com.almworks.jira.structure')

StructureComponents structureComponents = ComponentAccessor.getOSGiComponentInstanceOfType(StructureComponents)
def structureManager = structureComponents.getStructureManager()

def structures = structureManager.getAllStructures(null)
def map = structures.collectEntries {
  [(it.name + ' (#' + it.id + ')'): it.permissions]
}

'<table><tr><th>Structure Name (ID)</th><th>permissions</th></tr>' +
map.collect {'<tr><td>' + Util.htmlEncode(it.key as String) + '</td><td>' + it.value + '</td></tr>'}.join('')  +
  '</table>'

The above script produces a list of structures and their permissions in the following format: [set:{%permission_level}:{%subject}:{%subject_identifier}"]

{%permission_level}

The level of permission:

  •  10 = View

  •  20 = Edit

  •  25 = Automate

  •  30 = Control

{%subject}

To whom the permission is set: group, project role, user, or anyone.

{%subject_identifier}

The group, role, or user with the permissions. The type of information depends on the subject:

  • group - the identifier is the group name (for example: jira-adminstrators)

  • role - the role is identified by the project id followed by the role id (for example: 10000:10002)

  • user - the identifier is the user key (for example: JIRAUSER10000) 

  • anyone - this does not require an identifier

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.