Hi,
We are trying to cleanup unused/inactive users Structures in JIRA, so planning to archive all the list by using Script but did not find any API to archive the structures please suggest the API to Archive structures in JIRA or share the Script to archive if any exists.
Thanks in Advance.
Regards,
Sriram.
Hello @Sriram Pallapothu ,
David from ALM Works here.
I saw that you contacted our customer team regarding this and Stepan was able to provide the solution. I wanted to add the solution here for other Structure users, that have the same question, to find.
The following script will archive all structures where the owner is an inactive user:
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 }
The script console might show some errors but should work regardless. You can see the list of archived structures in the Result tab after running the script.
Best,
David
Hi David,
Thanks for the script, it worked well and now we are able to archive structures.
Regards,
Sriram.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Last time script has been worked to archive all the inactive owner structures, 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Last time script has been worked to archive all the inactive owner structures, 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I Found script to delete the structure as follows
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
// Grab only useful for IDE help, not for runtime. Alternatively you can just add this jar to the
// "provided" scope for the module
@grab(group = 'com.almworks.jira.structure', module = 'structure-api', version = '16.0.0')
// Specify that classes from this plugin should be available to this script
@WithPlugin("com.almworks.jira.structure")
// Inject plugin module
@PluginModule
StructureComponents structureComponents
//Structure ID need to delete
def structureList = [ ]
def structureManager = structureComponents.getStructureManager()
for(structureID in structureList ){
structureManager.deleteStructure(structureID)}
By using this script able to delete the structure but unable to archive, anyone please suggest me is there any method to archive structures
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sriram Pallapothu ,
this script is based on third part app. Jira has not the concept of archive for structures. You can just archive issues/projects on data center instances
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sriram Pallapothu ,
I did that type of tasks in the past for different customers. My suggestion is to use a third app https://marketplace.atlassian.com/apps/6398/jira-command-line-interface-cli?tab=overview&hosting=server provided by Appfire that contains a lot of features in order to cleanup a JIRA instance.
Hope this helps,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio,
Thanks for your valuable suggestion, But is there any suggestion with out add-on why because using of additional add-on requires many approval and will be cost related. so any suggestion by using script or API
Regards,
Sriram.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.