Skip to main content
Skip table of contents

Set the View Permission in All Structures

This script will set/override other existing permissions in all structures with the View permission given to the 'jira-software-users' user group.

CODE
package examples.docs.structure

import com.atlassian.jira.component.ComponentAccessor
import com.almworks.jira.structure.api.permissions.PermissionLevel
import com.almworks.jira.structure.api.permissions.PermissionRule
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.almworks.jira.structure.api.StructureComponents


@WithPlugin('com.almworks.jira.structure')
@PluginModule
 
StructureComponents structureComponents


def structureManager = structureComponents.getStructureManager()
def permission = PermissionLevel.valueOf("ADMIN")
def allStructures = structureManager.getAllStructures(permission).collect {it -> it.id}

allStructures.each{
   def str=structureManager.getStructure(it,permission)
    log.warn(str)
   def p = PermissionRule.decodePermissions("set:10:group:jira-software-users")
   str.setPermissions(p)
    str.saveChanges()
}
JavaScript errors detected

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

If this problem persists, please contact our support.