Is there any script to pass specific Structure ID's or names and to archive only those structures.
Why because we identified few structures for which owners are active and not using so we want to archive those Structures for few days if no one comes back after specific time interval we will delete them.
Please suggest to archive structures by using ID or structure names.
Hi @Sriram Pallapothu For this you need scriptrunner plug-in and run following script in script console , it archives all the structure in which owner is an inactive user :-
Thanks to Script creator / owner @David Niro
import com.atlassian.jira.component.ComponentAccessor
def plugin = ComponentAccessor.pluginAccessor.getPlugin('com.almworks.jira.structure')
def loader = plugin.classLoader
def PermissionLevel = loader.loadClass('com.almworks.jira.structure.api.permissions.PermissionLevel')
def StructureAuth = loader.loadClass('com.almworks.jira.structure.api.auth.StructureAuth')
def structureComponents = plugin.getModuleDescriptor('structure-components').module
def structureManager = structureComponents.structureManager
StructureAuth.sudo {
def activeStructures = structureManager.getAllStructures(PermissionLevel.NONE, false)
def structuresToArchive = activeStructures.findAll { it.owner != null && !it.owner.isActive() }
structuresToArchive.forEach {
it.setArchived(true).saveChanges()
log.warn("Archived structure: ${it.id} - ${it.name}")
}
structuresToArchive
}
Thanks
V.Y
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.