您好我是groovy的新手,我正在尝试使用jenkins获取tfs changset的编辑类型,但是,当尝试访问编辑类型时,我收到此错误:
13:17:50 groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.getEditType() is applicable for argument types: () values: []
13:17:50 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
13:17:50 at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49)
13:17:50 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
13:17:50 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
13:17:50 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
13:17:50 at Script1.run(Script1.groovy:66)
13:17:50 at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
13:17:50 at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
13:17:50 at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
13:17:50 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:343)
13:17:50 at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
13:17:50 at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
13:17:50 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
13:17:50 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
13:17:50 at hudson.model.Build$BuildExecution.build(Build.java:206)
13:17:50 at hudson.model.Build$BuildExecution.doRun(Build.java:163)
13:17:50 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
13:17:50 at hudson.model.Run.execute(Run.java:1727)
13:17:50 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
13:17:50 at hudson.model.ResourceController.execute(ResourceController.java:97)
13:17:50 at hudson.model.Executor.run(Executor.java:429)
它失败的路线是:
// work with current build
def build = Thread.currentThread()?.executable
// get ChangesSets with all changed items
def changeSet = build.getChangeSet()
def items = changeSet.getItems()
println "Affected Files"
def filez = items.collect{
it.getAffectedFiles()
}
println filez
println "Edit Type"
def edittype = filez.getEditType()
println edittype
我知道这是一个令人注意的问题,但我确实对所发生的事感到困惑。我试着打电话给.toString
,认为它正在返回一个无法打印的对象,但事实并非如此。
答案 0 :(得分:0)
您正在调用集合上的方法而不是基础类型。将它包装在for循环中,添加另一个collect
或使用扩展点运算符(*.
)来调用该方法。例如
filez*.getEditType()