我是Groovy和Jenkins的初学者。我尝试以Freestyle项目开始工作
我添加了 Buid>添加构建步骤>执行groovy脚本并输入如下代码
#!/usr/bin/env groovy
import hudson.model.*
import hudson.AbortException
import hudson.console.HyperlinkNote
import java.util.concurrent.CancellationException
// Start another job
def job = Hudson.instance.getJob('mhi_job_test2')
def anotherBuild
try {
//def future = job.scheduleBuild()
println "Waiting for the completion of " + job.url + "\nName:"+job.fullDisplayName // HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
//anotherBuild = future.get()
} catch (CancellationException x) {
throw new AbortException("${job.fullDisplayName} aborted.")
}
我尝试按链接http://localhost:8080/script运行脚本。它运作良好
但是缺少依赖性
[job_decision] $ D:path-to-groovy-home \ groovy-2.4.7 \ bin \ groovy.bat
,无法加载类hudson.model.Hudson
D:path-to-jenkin \ Jenkins \ workspace \ job_decision \ jenkin.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:
类生成期间的常规错误:java.lang.NoClassDefFoundError:由于缺少依赖性hudson / remoting / VirtualChannel,无法加载类hudson.model.Hudson java.lang.RuntimeException:java.lang.NoClassDefFoundError:由于缺少依赖性hudson / remoting / VirtualChannel