简体   繁体   中英

groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList

Hi I'm new to groovy and I am trying to get the edit type of a tfs changset using jenkins, however, when trying to access the edit type I get this error:

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)

The line it is failing on is:

// 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

I know this is a nooby question however I truly am confused what is happening. I tried calling .toString thinking it was returning an object that can't be printed however that was not the case.

You are calling the method on the collection instead of the underlying type. Either wrap it in a for loop, add another collect or use the spread dot operator ( *. ) to call the method. eg

filez*.getEditType()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM