As suggested in https://wiki.almworks.com/display/structure/Creating+a+New+Structure+Programmatically I am trying to create a new structure, if it doesnt exists via script runner (5.5.7). But I get below error
"org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.almworks.jira.structure.AllPublicStructureComponents@16b28350' with class 'com.almworks.jira.structure.AllPublicStructureComponents' to class 'com.almworks.jira.structure.api.StructureComponents'"
Any clue on whats going wrong.
Script runner version : 5.5.7
Structure version 5.4.0
JIRA Server version 7.10.1
Thanks
Hi Akshatha,
I think you should try the following script:
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
@WithPlugin("com.almworks.jira.structure")
@PluginModule
StructureComponents structureComponents
// the name of the new structure
final String structureName = "YOUR_STRUCTURE_NAME"
def structureManager = structureComponents.structureManager
// if structure with the given name doesn't exist, create a new empty one
if (!structureManager.getStructuresByName(structureName, PermissionLevel.ADMIN)) {
structureManager.createStructure().setName(structureName).saveChanges()
}
Furthermore, I'd like to point you over to the Adaptavist Library, in particular the ScriptRunner and Structure section here. It should provide you with more curated examples. And otherwise they'd be happy to help if you file a support ticket.
Best,
Phil Heijkoop
Solutions Engineer
ALM Works
Hello,
I have same problem with my script:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.almworks.jira.structure.AllPublicStructureComponents@5ad942e8' with class 'com.almworks.jira.structure.AllPublicStructureComponents' to class 'com.almworks.jira.structure.api.StructureComponents'
and I am using recommended syntax:
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.almworks.jira.structure.api.StructureComponents
import org.apache.log4j.Level
import org.apache.log4j.Logger
@WithPlugin("com.almworks.jira.structure")
@PluginModule
StructureComponents sc
def log = Logger.getLogger("VALID_SCRIPT_issuesLinkedOnPpmIssue.groovy")
log.setLevel(Level.DEBUG)
...
...
...
But this error is still showing. For example yesterday it worked and today again this error, even whn I didn't even touch script. Can you explain me how to avoid this error and work normally with StructureComponents? I am loosing my mind...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrej,
Sorry you're getting this error. Can you tell me which versions of Jira, Structure and ScriptRunner you're on?
Alternatively, for more targeted help you can submit a support ticket either with us via support@almworks.com or at Adaptavist, depending on your exact needs.
Best,
Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Philip,
I am a colleague of Andrej, so I am well informed about this issue in our Jira environment.
We are using
(Andrej also should submit a ticket on behalf of our client we are working for.)
I also tried to use
...
import com.almworks.jira.structure.AllPublicStructureComponents @PluginModule AllPublicStructureComponents structureComponents
...
But it did not work as well. Additionally, there is another error in the IDE while the class is not in the ...structure.api.* package under the appropriate Maven artifact).
Maybe this could help you: I have just realised that the script using the documented construction (the StructureComponents class) works fine from Script Console but not from a script saved to the scriptRoots.
Is there something special to set for using the scriptRoots for the Structure plugin???
Thank you very for help.
Best regards,
Vitek
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.