Hello Team,
Thanks in advance.
Normally , Manually I am able to add structure inside structure.
By following below steps
Automation >> + sign >> insert >> Structure >> structure name >> Done
I want to automate this process using scriptrunner
Hello @Pavan
You can try the script below:
package examples.docs.structure
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.atlassian.jira.component.ComponentAccessor
import com.almworks.jira.structure.api.structure.Structure
import com.almworks.jira.structure.api.forest.action.ForestAction
import com.almworks.jira.structure.api.forest.ForestSpec
import com.almworks.jira.structure.api.item.CoreIdentities
import com.almworks.jira.structure.api.generator.CoreGeneratorParameters
@WithPlugin("com.almworks.jira.structure")
@PluginModule
StructureComponents structureComponents
def parentStructureName = "Parent" // name of the structure you want to add this generator to
def innerStructureName = "Inner" // name of the structure to add
def structureManager = structureComponents.getStructureManager()
def forestService = structureComponents.getForestService()
def generatorManager = structureComponents.getGeneratorManager()
def permission = PermissionLevel.valueOf("ADMIN")
def parentStructureId = structureManager.getStructuresByName(parentStructureName, permission)[0].getId()
def innerStructureId = structureManager.getStructuresByName(innerStructureName, permission)[0].getId()
// inserter
def params = ['forestSpec' : ['structureId' : innerStructureId]]
def inserterId = generatorManager.createGenerator("com.almworks.jira.structure:inserter-substructure", params, parentStructureId)
def generatorItem = CoreIdentities.generator(inserterId) // item to add to forest
def forestSource = forestService.getForestSource(ForestSpec.structure(parentStructureId)) //resolving forest source for structure
forestSource.apply(new ForestAction.Add(generatorItem, 0, 0, 0))
I hope this helps. If you need our assistance with anything, please feel free to contact us directly at support.almworks.com and we'll get back to you shortly.
Best regards,
Stepan Kholodov
ALM Works
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.