-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Critical
-
Component/s: configuration-as-code-groovy-plugin
-
None
-
Environment:Jenkins 2.319.3
Trying to use customized class as enum type value, below script works in script console, but hit below runtime error. Works fine when enum value is String array instead of ProductInfo array.Â
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.vmware.vc.cicd.utils.WCPHelper$ProductInfo(java.lang.String, com.vmware.vc.cicd.utils.WCPHelper$InforType)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1732)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1532)
at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:49)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:255)
// Value type available for Param Type
enum InfoType {
 BUILD_WEB,
 URL,
 STRING
}
// Name and value type available for ProductType
class ProductInfo {
 String product
 InfoType type
 Â
 ProductInfo(product, type)
}
// Product names whose value could be buildweb build or URL or any string type
enum ProductType {
   AA_BUILD(new ProductInfo('test1', InfoType.BUILD_WEB),
      new ProductInfo('test2', InfoType.BUILD_WEB)),
  BB_BUILD(new ProductInfo('test3', InfoType.BUILD_WEB)),
  CC_BUILD(new ProductInfo('test4', InfoType.BUILD_WEB),
         new ProductInfo('test5', InfoType.BUILD_WEB),
         new ProductInfo('test6', InfoType.URL))
 Â
  private ProductInfo[] productInfos
  Â
  ProductType(ProductInfo... productInfos)
  Â
  public ProductInfo[] getProductInfos()
}
productType = ProductType.CC_BUILD
ProductInfo[] productInfos = productType.getProductInfos()
boolean isValidParam = false
productInfos.eachWithIndex { prdInfo, index ->
 println prdInfo.type
}
Result
BUILD_WEB
BUILD_WEB
URL
Result: [LProductInfo;@398b1462