我在Jenkins 1.501上安装了脚本编辑器插件:
https://wiki.jenkins-ci.org/display/JENKINS/Scriptler+Plugin
我创建了这个脚本:
import org.apache.commons.httpclient.*
import org.apache.commons.httpclient.auth.*
import org.apache.commons.httpclient.methods.*
@Grab(group='commons-httpclient', module='commons-httpclient', version='3.1')
void createNewJenkinsProject() {
out.println("Test")
}
createNewJenkinsProject()
基于这个例子:
https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients
在我的一个奴隶的工作上,我将上面的脚本添加为构建步骤。当我建立这份工作时,我得到了:
Execution of script [move-projects.groovy] failed - java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReportorg.jenkinsci.plugins.scriptler.util.GroovyScript$ScriptlerExecutionException: java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport
at org.jenkinsci.plugins.scriptler.util.GroovyScript.call(GroovyScript.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport
答案 0 :(得分:4)
如果您已选择"执行系统Groovy脚本"作为构建操作,然后这将在Jenkins master上运行。因此,请确保类路径中存在所有必需的jar。您甚至可以在使用之前检查脚本。为此,请转到your-jenkins-url / jenkins / script并粘贴脚本并测试
如果"执行Groovy Script"选择选项,确保罐子位于从属的类路径中。