You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Add Folder to a Structure


Structure for Jira allows you to create structures to organise issues and projects. This script adds a folder to a structure, allowing you to separate and organise issues.


As a project manager, I want to separate issues in groups inside my structure. Using this script, I can easily create multiple folders to organise my issues within a structure.

Good to Know


  • Jira Jira (7.7 - 8.6)
  • ScriptRunner for Jira ScriptRunner for Jira (5.6.14)
import com.almworks.jira.structure.api.permissions.PermissionLevel import com.almworks.jira.structure.api.StructureComponents import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.almworks.jira.structure.api.folder.Folder import com.almworks.jira.structure.api.forest.action.ForestAction import com.almworks.jira.structure.api.forest.ForestSpec import com.almworks.jira.structure.api.forest.item.ItemForestBuilderImpl import com.almworks.jira.structure.api.item.CoreIdentities @WithPlugin("com.almworks.jira.structure") @PluginModule StructureComponents structureComponents // Get components def structureManager = structureComponents.structureManager def folderManager = structureComponents.folderManager def forestService = structureComponents.forestService // Define the params (name of the structure, permission level of the structure and folder name) final structureName = 'My structure' final permissionLevel = PermissionLevel.ADMIN final newFolderName = 'My folder' def structures = structureManager.getStructuresByName(structureName, permissionLevel) if (!structures) { log.warn "No existing Structure found with name '${structureName}' and permission level '${}'" return } def structureId = structures.first().id // Create the folder associated with the structure def newFolder = Folder.named(newFolderName).setOwningStructure(structureId).build() def folderItem = folderManager.createFolder(newFolder) def forestBuilder = new ItemForestBuilderImpl() forestBuilder.nextRow(CoreIdentities.folder(folderItem)) // Add the folder to the structure def forestSource = forestService.getForestSource(ForestSpec.structure(structureId)) def forestToAdd = forestSource.apply(new ForestAction.Add(forestToAdd, 0, 0, 0))
Discovered an issue? Report it here

Suggested for you

Appears in these Collections