This is a request to implment 'New Feature'.
Please refer to below url.
https://track.pmease.com/browse/QB-3568
Thanks to reply it.
However, it doesn't make sense and does not work.
I think that I need to tell you the scenario with the code.
here is my funcA
${groovy:
def print_log(String s) {
logger.debug(s);
\}
}
I want to use this 'print_log' in any step.
Please let me know what I have to do.
You may define a variable say "utils" and define common functions, for instance:
def print_log(String s) {
logger.debug(s);
}
Then anywhere you want to call print_log, write it like below:
groovy:
def utils = Eval.me("logger", logger, vars.getValue("utils"));
utils.print_log("some log message");
I created a variable 'utils' and a step 'test_command' as following your comment.
Unfortunately, it says null point exception like shown below.
Could you check it, once again?
ERROR - Step 'master>test command' is failed: java.lang.NullPointerException: Cannot invoke method print_log() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at script15890722679861485409386.run(script15890722679861485409386.groovy:4)
at com.pmease.quickbuild.plugin.basis.BasisPlugin$32.evaluate(BasisPlugin.java:382)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:305)
at com.pmease.quickbuild.DefaultScriptEngine....
I really appreciate it your replies, it works well.
It might be the last question regarding this.
Could you let me know how do I use various class?
def utils = Eval.me("logger", logger, utils_src);
In this case, only "logger" class can use in 'utils_src'.
I would like to use not only "logger", but also others.
You can pass a map and access various objects via the map. For instance:
def utils = Eval.me("context", ["logger": logger, "build": build], utils_src);
In your utils src you can access context.logger, context.build, etc.