Here is a solution that does work in both Groovy and Jenkins

    def foundRootNode = null
    for(file in files) {
        final def rootNode = findByContent(file.getPath());
        if (rootNode != null) {
            foundRootNode = rootNode
            break;
        }
    }

However it is not as elegant as using Java Stream API.
søndag 7. februar 2021 kl. 19:00:39 UTC+1 skrev Sverre Moe:

>
> The following piece of code works fine in Groovy, but Jenkins complains 
> about unexpected token: ->
>
>     final def files = findFiles(glob: filePattern)
>     final def rootNode = files.stream()
>         .map(file -> findByContent(file.getPath()))
>         .filter(node -> node != null)
>         .findFirst()
>
> To get this working in a local Groovy script the findFile is switched with 
> a simple List of strings.
>
> So why is it not working in Jenkins?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5b921dcf-2f8d-45ff-86c6-5640925c7c04n%40googlegroups.com.

Reply via email to