-
Bug
-
Resolution: Unresolved
-
Critical
-
None
-
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
// 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
Result
BUILD_WEB
BUILD_WEB
URL
Result: [LProductInfo;@398b1462