0

I am trying to extract a list of CL in a depot that matches a certain description and i dont have a success. below is my code and the error i get

 /* ALL MY IMPORTS */
 /* MY PERFORCE AND HTTP modules using grapes */

  /* SERVER LOGIN CONDITIONS */
List<IFileSpec> fileList = server.getDepotFiles(FileSpecBuilder.makeFileSpecList("//depot/release/prod/..."), false)
List<IChangelistSummary> changelistList = server.getChangelists(fileList,null)
def clList = [:]
def discl = []
if (changelistList != null) {
 changelistList.each { IChangelistSummary cl ->
    if (cl.getId() != null) {
        println cl.getId()
        IChangelist cld = server.getChangelist(cl.getId())
       println cld.getDescription()

     if(!(discl.contains(cl.getId())) && !(cl.getDescription().startsWith("Build with EF")) && !(cl.getUsername().matches("mb_ccatt")) ){
          discl << cl.getId
        clList.put(cl.getId(),cl.getUsername())
      }
   }
 }
}
   clList.each{ key,value ->
   println "\t$key: $value"
 }
 server.disconnect()

Below is the log, as you see till certain extent all the print statments look good, and suddenly it throws a exception

    com.perforce.p4java.impl.generic.core.User@55322aab

Which i dont understand where from it is getting User index?

192359
Prod Copy Up using p4 copy from Dev-XXX to ZZZZ-Release using newly created label Dev-XXX.CCversion-XXX.20180212_103004.ICM730.COPY_UP_depot_mode

194118
Merging from ZZZZ-Release PARENT CL 194248   Yadav __ Description: 1802_UAT_Defect1234_Change

  com.perforce.p4java.impl.generic.core.User@55322aab
  Caught: groovy.lang.MissingPropertyException: No such property: getId for 
  class: com.perforce.p4java.impl.generic.core.ChangelistSummary
  groovy.lang.MissingPropertyException: No such property: getId for class: 
  com.perforce.p4java.impl.generic.core.ChangelistSummary
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
    at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
    at cllist_new$_run_closure1.doCall(cllist_new.groovy:34)
    at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
    at groovy.lang.Closure.call(Closure.java:414)
    at groovy.lang.Closure.call(Closure.java:430)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066)
    at org.codehaus.groovy.runtime.dgm$163.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at cllist_new.run(cllist_new.groovy:27)
    at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
    at groovy.lang.GroovyShell.run(GroovyShell.java:518)
    at groovy.lang.GroovyShell.run(GroovyShell.java:507)
    at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)
    at groovy.ui.GroovyMain.run(GroovyMain.java:384)
    at groovy.ui.GroovyMain.process(GroovyMain.java:370)
    at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
    at groovy.ui.GroovyMain.main(GroovyMain.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
DevOops
  • 276
  • 2
  • 8
  • 20

1 Answers1

1

I suspect that the problem here is that getId is a method, not a property, so you can't write:

discl << cl.getId

you have to write

discl << cl.getId()
Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • Excellent, Thank you very much, sometimes we visualize the problem to be so big, we overlook the minute details. An extension to the above do you know how to check which group a user belong to if i have a changelist form which i can extract the username? – DevOops Mar 08 '18 at 23:02
  • 1
    The same script after fixing the getId() , it executes parse few Changelists and all of a sudden throws Perforce Connection issue , in real there is no connection issue.. Any help? – DevOops Mar 09 '18 at 06:31
  • Sounds like we should address that as a new question, with as much detail as you can provide. – Bryan Pendleton Mar 10 '18 at 17:34