Jenkins Scriptler的“限制”设置有什么作用?

时间:2016-02-10 20:20:29

标签: jenkins-scriptler

我有以下Scriptler脚本:

println build.environment

如果选中Restriction,则脚本可以正常工作。但如果没有检查,则会出错:

Execution of script [example.groovy] failed - Remote call on example failedjava.io.IOException: Remote call on example failed
    at hudson.remoting.Channel.call(Channel.java:757)
    at org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder.perform(ScriptlerBuilder.java:116)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
    at hudson.model.Build$BuildExecution.build(Build.java:203)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Caused by: java.lang.ClassNotFoundException: Script1
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
    at hudson.remoting.MultiClassLoaderSerializer$Input.resolveClass(MultiClassLoaderSerializer.java:116)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
    at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1484)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1334)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:501)
    at java.lang.Throwable.readObject(Throwable.java:914)
    at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
    at hudson.remoting.UserRequest.deserialize(UserRequest.java:185)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:218)
    at hudson.remoting.Channel.call(Channel.java:753)
    ... 10 more
Build step 'Scriptler script' marked build as failure
Finished: FAILURE

1 个答案:

答案 0 :(得分:0)

'约束'将脚本的执行限制为主节点。至于为什么你不能从脚本中打印build.environment,也许this article会有所帮助。