我試圖使用Groovy腳本來收集來自詹金斯數據,卻得到了錯誤:無法解析類com.cloudbees.hudson.plugins.folder.Folder
unable to resolve class com.cloudbees.hudson.plugins.folder.Folder
下面是代碼:
import jenkins.model.*
import hudson.model.*
import groovy.time.TimeCategory
use (TimeCategory) {
// e.g. find jobs not run in last 1 year
sometimeago = (new Date() - 1.year)
}
jobs = Jenkins.instance.getAllItems()
lastabort = null
jobs.each { j ->
if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return }
numbuilds = j.builds.size()
if (numbuilds == 0) {
println 'JOB: ' + j.fullName
println ' -> no build'
return
}
lastbuild = j.builds[numbuilds - 1]
if (lastbuild.timestamp.getTime() < sometimeago) {
println 'JOB: ' + j.fullName
println ' -> lastbuild: ' + lastbuild.displayName + ' = ' + lastbuild.result + ', time: ' + lastbuild.timestampString2
}
}
的錯誤是:
rg.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 12: unable to resolve class com.cloudbees.hudson.plugins.folder.Folder @ line 12, column 20. if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return }^1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
的錯誤是rg.codehaus.groovy.control.MultipleCompilationErrorsException:啓動失敗: Script1.groovy:12:無法解析類com.cloudbees.hudson.plugins.folder.Folder @ 12行,列20 。 如果(j的instanceof com.cloudbees.hudson.plugins.folder.Folder){返回} ^ 1錯誤 \t在org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302) – sbobba