

It finds all values in the receiving object matching the closure condition. The find method finds the first value in a collection that matches some criterion. The closures themselves provide some methods. The list will only display those numbers which are divisible by 2. When we run the above program, we will get the following result −

The above example shows the conditional if(num % 2 = 0) expression being used in the closure which is used to check if each item in the list is divisible by 2. I was not able to find a prior version in which this bug disappears, but I'm thinking that this might be caused by the Pipeline: Groovy plugin since that was recently upgraded several versions.Īt .CpsTransformer.visitMapEntryExpression(CpsTransformer.java:944)Īt .(MapEntryExpression.java:39)Īt .CpsTransformer.visit(CpsTransformer.java:346)Īt .CpsTransformer$24.run(CpsTransformer.java:834)Īt .CpsTransformer.makeChildren(CpsTransformer.java:435)Īt .CpsTransformer.makeNode(CpsTransformer.java:398)Īt .CpsTransformer.visitBinaryExpression(CpsTransformer.java:829)Īt .(BinaryExpression.java:51)Īt .CpsTransformer.visitExpressionStatement(CpsTransformer.java:577)Īt .(ExpressionStatement.java:42)Īt .CpsTransformer.visit(CpsTransformer.java:352)Īt .CpsTransformer$5.run(CpsTransformer.java:503)Īt .CpsTransformer.visitBlockStatement(CpsTransformer.java:500)Īt .(BlockStatement.java:71)Īt .CpsTransformer$2.run(CpsTransformer.java:377)Īt .CpsTransformer.visitWithSafepoint(CpsTransformer.java:363)Īt .CpsTransformer.visitMethod(CpsTransformer.java:222)Īt .CpsTransformer.call(CpsTransformer.java:132)Īt .CompilationUnit.applyToPrimar圜lassNodes(CompilationUnit.java:1065)Īt .CompilationUnit.doPhaseOperation(CompilationUnit.java:603)Īt .CompilationUnit.processPhaseOperations(CompilationUnit.java:581)Īt .pile(CompilationUnit.java:558)Īt 圜lassLoader.doParseClass(Groov圜lassLoader.java:298)Īt 圜lassLoader.parseClass(Groov圜lassLoader.java:268)Īt 圜lassLoader.parseClass(Groov圜lassLoader.java:254)Īt 圜lassLoader.recompile(Groov圜lassLoader.java:761)Īt 圜lassLoader.loadClass(Groov圜lassLoader.java:718)Īt 圜lassLoader.loadClass(Groov圜lassLoader.java:787)Īt (Unknown Source)Īt .cps.CpsGroovyShell$TimingLoader.loadClass(CpsGroovyShell.java:158)Īt 圜lassLoader.loadClass(Groov圜lassLoader.java:677)Īt 圜lassLoader.loadClass(Groov圜lassLoader.java:545)Īt .yAsLoaderClassOrScript(ClassNodeResolver.java:185)Īt .ClassNodeResolver.findClassNode(ClassNodeResolver.java:170)Īt .ClassNodeResolver.resolveName(ClassNodeResolver.java:126)Īt .ResolveVisitor.resolveToOuter(ResolveVisitor.java:676)Īt .ResolveVisitor.resolve(ResolveVisitor.java:313)Īt .ResolveVisitor.visitClass(ResolveVisitor.java:1236)Īt .ResolveVisitor.startResolving(ResolveVisitor.java:176)Īt .CompilationUnit$12.call(CompilationUnit.java:663)Īt .CompilationUnit.applyToSourceUnits(CompilationUnit.java:943)Īt .CompilationUnit.doPhaseOperation(CompilationUnit.java:605)Īt .pile(CompilationUnit.java:554)Īt (GroovyShell.java:688)Īt (GroovyShell.java:700)Īt .(CpsGroovyShell.java:131)Īt .(CpsGroovyShell.java:125)Īt .(CpsFlowExecution.java:560)Īt .(CpsFlowExecution.java:521)Īt .(WorkflowRun.// This time the $param parameter gets replaced by the string "Inner"ĭef clos = I've tried reverting the versions of both Jenkins and the plugin and this bug exists in the following versions: This version of sayHello will work and will print "Hello from Foo!" to theĭef mapVariable = įinally, I want to mention that we are pretty sure that the original code, which was directly passing literal map values to another method, was working in prior versions of Jenkins and the Pipeline: Groovy plugin.

I've reproduced this error for the following toy case: There should not have been any compilation from this call. Passing a map literal value to a custom step function inside of a shared library appears to cause an "UnsupportedOperationException" and gives the following error messageīUG! exception in phase 'semantic analysis' in source unit 'WorkflowScript' The lookup for foo.Foo caused a failed compilaton. Pipeline-model-declarative-agent 1.1.1 true Global-variable-string-parameter 1.2 true

Passing map literal values to method in shared library causes UnsupportedOperationExceptionĪpache-httpcomponents-client-4-api 4.5.5-3.0 trueĬloudbees-bitbucket-branch-source 2.2.12 true
