How to use ScriptManager Class from Groovy Runner?

I have tried to retrieve it with ComponentAccessor/ComponentManager. But no luck, it returns null and

GroovyClassLoader gcl = scriptManager.getGcl()

def renameUser = gcl.loadClass("com.onresolve.jira.groovy.canned.admin.RenameUser", true, false).newInstance();

fails with error "Cannot invoke method getGcl() on null object"

I tried both

def scriptManagerClass = ComponentAccessor.getPluginAccessor().getClassLoader().loadClass("com.onresolve.jira.groovy.ScriptManager")

def scriptManager = ComponentAccessor.getOSGiComponentInstanceOfType(scriptManagerClass)

and

def scriptManager = (ScriptManager) ComponentAccessor.getComponent(ScriptManager.class);

but it returns a null.

I am trying to write a script to merge multiple users. Any suggestions?


1 answer

1 accepted

0 vote
Henning Tietgens Community Champion Feb 18, 2014

Why you need the the ScriptManager? Simply write your script and execute via script console, this is how I do it. Or do you have any special needs for the ScriptManager?

Hi Henning,

I am trying to reuse the RenameUser from inbuilt "Rename User ID" script to "merge" multiple users. If that works, instead of making changes to the inbuilt scripts or rewriting the whole script , features can be used. There are some examples here https://bitbucket.org/fhess/scriptrunner-public/src/522c5c99ab52/src/test/resources/examples/RenameDuplicateUsers.groovybut it's not working anymore.

Thanks

Henning Tietgens Community Champion Feb 18, 2014

If you try to reuse scripts from script runner, I think you have to take care to use the same package (and the corresponding path for the script). Than there should be no problem on using other script runner classes.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

857 views 2 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you