Script Runner Addon - Custom scripts as post-function with parameters

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

I followed @jamie-echlin's instructions to create my own script available on the classpath, and it is visible/runs from the PLugins>Built-In Scripts page.

https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Built-InScriptsHackingNotes

However I want it to also show as a post-function, so I tried adding both "Function" and "Listener" to the categories with no luck.

List getCategories() {
        ["ADMIN","Function","Listener"]
    }

I'd prefer not to just use the full path to the file because then I would need to hard code the arguments rather then using parameters

Workflow Script Post-Function screen

Admin Screen

By the way, my end goal is to populate a custom field based on the summary of an email-generated ticket, so if anyopne has an alternate approach let me know.

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2013

I just tested this and it worked fine, which surprised me a bit.

It will only show in the post-functions, then you have to click the post-function labelled Script Post-Function, and it will be in there.

But I see you have done that so I have no idea. Oh actually.... the package needs to be this or under this: com.onresolve.jira.groovy.canned.workflow.postfunctions

I bet that's the problem. That's a bit pants, sorry.

> By the way, my end goal is to populate a custom field based on the summary of an email-generated ticket, so if anyopne has an alternate approach let me know.

What are you planning to do - read a mailbox and generate tickets? If so don't you want a service...?

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2013

Oo, I'll give that a try first thing this morning, thanks Jamie!

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2013

Woot!

Changed the package as suggested AND moved to the same folder structure in WEB-INF/classes.

Function shows up as expected now - Thanks Jamie!

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2013

Doh, now I am getting an NPE. (even running from admin console)

javax.script.ScriptException: javax.script.ScriptException: java.lang.NullPointerException
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
	at javax.script.AbstractScriptEngine.eval(Unknown Source)
	at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:110)
	at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:61)
	at com.onresolve.jira.groovy.GroovyRunner.doExecute(GroovyRunner.java:244)

Any advice for setting a cascading select from groovy script? I'm sure you have a nifty library that does it in one easy call!

This page is poorly written, and full of errors, https://confluence.atlassian.com/display/JIRACOM/How+to+Set+the+value+of+a+cascading+select+list+in+an+issue.?from=sac_createissue

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2013

Nm, i'm an idiot. Returning null from your method when a map is expected is a good way to cause NPEs!

Also for anyone else working to update cascading select lists with Jamie's plugin, I added my short snippet as a comment to this page https://confluence.atlassian.com/display/JIRACOM/How+to+Set+the+value+of+a+cascading+select+list+in+an+issue.?focusedCommentId=394464833#comment-394464833

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2013

You seem to be hitting some of the more obtuse problems in the code. BTW the code you forked is not uptodate... if you send me your bitbucket id to myfirstname dot mylastname @gmail.com I will give you read access to the live repo.

But, I'm away for a while now, will be towards the end of next week...

Rasmus Lock Fuglsang May 12, 2014

Note! Most of the links in the above posts are now dead :/

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 20, 2013

Sorry for the delay @Jamie. It did not work.

After a restart script continues to show in "built-in" but not "post-functions"

I would be happy to provide the script or anything else you would need if you want to try and re-create the issue.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2013

it should be compiled on the fly, but do try restarting... LMK if that works.

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2013

Unfortunately no. I'll add the contrasting screenshots between the post-function view (after choosing "script post-function") and the admin run screen.

No error shows in logs, and I don't think it is a compilation issue as I can view and run it from the "built-in scripts" page (see 2nd screenshot)

Wondering if I need to restart JIRA, I assumed the classpath for groovy post-function compilied on the fly too (like it is for the built-in script page) - but perhaps not.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2013

In the list of post-functions, you need to click "Script function" (or similar, and it should show there). Doesn't it?

If not check the logs at the time you click the "script function" link, if there are compilation errors it won;t be shown but a message will be logged.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events