java - Jenkins Pipeline Collection method grep -


i trying use method grep java.util.collection inside declarative pipeline, seems have different signature. in script console can execute following simple example code, without problems:

[1,2,3,4].grep({ == 4 }) 

it returns array containing element 4, want. when execute similar code inside pipeline however, returns boolean, not not want to, doesn't return true, when finding something, false.

pipeline {   agent {     label 'cloud-ubuntu-slave'   }   options {       timestamps()   }       stages {     stage ('debug') {       steps {         script {           echo "${[1,2,3,4].grep({ == 4 })}"         }      }    }  } 

i suspect given pipeline context, executes different method named grep, rather 1 collection, despite fact code same, haven't been able find out why or how change this.

what strange, able execute methods collection (e.g. collect) correctly.

this simplified example of i'm doing. want filter of collection based on lambda function returning true , false. alternative solution, doesn't involve iterating through , manually building new array, current, ugly workaround, equally welcome.

use ${[1,2,3,4].findall { == 4 }} instead, same grep in case.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -