onresolve canned.utils.WorkflowUtils and jar locations

SteveK January 12, 2014

This is one of those problems that make an otherwise intellgent person feel kinda dumb...like I half-anticipate Jamie will come on here with a simple answer and i'll slap my forehead but here we go:

I've gotten pretty good at listeners but taking my first crack at postfunction "canned" script and got some serious head-scratching going on here. First,

the script examples includes a helpful object "com.onresolve.jira.groovy.canned.utils.WorkflowUtils" to pull out params like this:

WorkflowUtils.getUser(params)

Unfortunately, adding the groovyrunner-2.1.15.jar to my <jira>\atlassian-jira\WEB-INF\lib and my IDEA class library does not resolve anything in the "utils" namespace? Even though those classes are clearly there and clearly in the library list in IDEA. See the short clip for proof I'm not crazy. ;)

http://screencast.com/t/3yvGe8GMC

Additional bonus question: I've had to grab the latest groovyrunner-n.n.n.jar out of my plugins directories because I can only find incidental references to that jar file online and they're all out-of-date. Is there a standard location to download the class libraries? (and source jar would be awesome too)

1 answer

1 accepted

0 votes
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.
January 12, 2014

Sorry... don't think there is a super simple answer. I think the problem is that many classes, eg that one, is not in the jar as a .class, it's in there as source.

When scripts get loaded the first time then all the dependent stuff is compiled (inside of jira). This is partly due to the mechanics of the groovy compilation process - when it's compiled for 6.0, it might well be incompatible with 6.0.1 if an additional constructor is added to some jira class that my class extends.

In the next major version they will also be shipped compiled, which helps a little with startup time.

I think you should be able to add the jar to the sources category, probably as well as the classes category, then IDEA should resolve it.

> Additional bonus question: I've had to grab the latest groovyrunner-n.n.n.jar out of

Don't really understand this one, you just get it from marketplace...?

> and source jar would be awesome too

As mentioned most of the stuff you want is in the "binary" jar as source... source for everything is not currently available.

Library should appear something like this:

SteveK January 12, 2014

Hi Jamie - wow, that was fast! Thank you.

I think I was anticipating a separate "SDK" jar location or something. I just get it from the version history! Makes sense.

So follow-on: Is it required then to extend a concrete class when implementing a post-function script? The reason I ask is that it writes to the log when I say, remove a method that is required when implementing the CannedScript interface, but when all methods are there, it fails silently.

Here's my class def:

class CreateMaintenanceIssueScript implements CannedScript {

...

then (for simplicity's sake) my doScript:

Map doScript(Map<String,Object> params) {
Logger log = Logger.getLogger(CreateMaintenanceIssueScript.class)

log.info("Begin Create Maintenance Request Script.")

return params

}

Prints nothing at all.

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.
January 12, 2014

Hi Steve... for a post-function you just want a plain old groovy script. They are simpler than listeners.

Implement CannedScript when you want another built-in script, ie one that can be parameterised and reused... But the internals of it are not well documented or exposed to end users.

Don't you just want a plain old script here, which you point to in your post-function...?

SteveK January 13, 2014

its hard to tell what runtime objects the scripts will have access to so I simply did a "view source" on your clone script and extrapolated from there. Turns out, with some requirements changes, we were able to use your (awesome) clone script as-is but, for future understanding, is there exhaustive doc on runtime script object references somewhere? The link seems to elude me. :S many thanks!

Suggest an answer

Log in or Sign up to answer