0

嗨,我是 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认为它正在返回一个无法打印的对象,但事实并非如此。

4

1 回答 1

0

您正在调用集合上的方法而不是基础类型。将其包装在 for 循环中,添加另一个collect或使用扩展点运算符 ( *.) 来调用该方法。例如

filez*.getEditType()
于 2018-04-26T17:34:32.190 回答