/
Creating a New Structure Programmatically

This article is for Data Center. Visit Cloud

Creating a New Structure Programmatically

Running the following script you can create a new structure.

package examples.docs.structure import com.atlassian.jira.component.ComponentAccessor import com.almworks.jira.structure.api.permissions.PermissionLevel import com.almworks.jira.structure.api.structure.Structure import com.almworks.jira.structure.api.StructureComponents import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin @Grab(group = 'com.almworks.jira.structure', module = 'structure-api', version = '16.9.0') @WithPlugin("com.almworks.jira.structure") @PluginModule StructureComponents structureComponents def structureManager = structureComponents.getStructureManager() def permission = PermissionLevel.valueOf("ADMIN") // It is important to check if an existing structure already exists; otherwise, this will create a new structure with the same name. if (structureManager.getStructuresByName("testScript", permission).isEmpty()){ log.warn "no existing Structure found" // It is important to note that without the saveChanges() call at the end, the new structure won't be saved to the database and will disappear after the script is run. structureManager.createStructure().setName("testScript").saveChanges() } else { log.warn "found a pre-existing structure" }



Related content

Changing Permission to Create New Structures
Changing Permission to Create New Structures
More like this
Delete Archived Structures
Delete Archived Structures
More like this
List Structure Names and Permissions
List Structure Names and Permissions
More like this
Archive Structures Owned by Inactive Users
Archive Structures Owned by Inactive Users
More like this
Creating Generators
Creating Generators
More like this