下面的代碼工作正常在Windows(詹金斯的常規腳本shell),但是當我執行它在Linux的詹金斯及其引發錯誤的Groovy腳本殼:詹金斯Groovy腳本在Windows上運行,但不是Linux
groovy.lang.MissingMethodException: No signature of method: sun.nio.fs.UnixPath.withReader() is applicable for argument types: (Script1$_run_closure1) values: [[email protected]] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at Script1.run(Script1.groovy:8) at org.jenkinsci.plugins.scriptler.util.GroovyScript.call(GroovyScript.java:122) at hudson.remoting.LocalChannel.call(LocalChannel.java:45) at org.jenkinsci.plugins.scriptler.util.ScriptHelper.runScript(ScriptHelper.java:124) at org.jenkinsci.plugins.scriptler.util.ScriptHelper.runScript(ScriptHelper.java:89) at org.jenkinsci.plugins.scriptler.ScriptlerManagement.doTriggerScript(ScriptlerManagement.java:470) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606)
下面是代碼;我通過爲Select_Folders
值:
import groovy.json.JsonSlurper
import java.nio.file.Paths
JsonSlurper slurper = new JsonSlurper()
def folder_struct
Paths.get('C:\\Json_Results\\results.json').withReader { reader ->
folder_struct = slurper.parse(reader)
}
return folder_struct [Select_Folders]
任何人都可以請幫助我的問題嗎?當然,在Linux上運行時,我已將路徑C:\\Json_Results\\results.json
更改爲/home/project/results.json
。
我的第一個問題將是路徑擴展只有在2.3.0之後纔在Groovy中使用 –