1

我已经在 J​​enkins 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
4

1 回答 1

5

如果您选择“执行系统 ​​Groovy 脚本”作为构建操作,那么它将在 Jenkins master 上运行。因此,请确保所有必需的 jar 都存在于类路径中。您甚至可以在使用脚本之前对其进行检查。为此,请转到 your-jenkins-url/jenkins/script 并粘贴脚本并进行测试

如果选择了“Execute Groovy Script”选项,请确保 jars 在从站的类路径中。

于 2013-02-15T13:50:57.160 回答