Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-42024

Silent error : UnsupportedOperationExceptions are not raised when using each/find

XMLWordPrintable

      Currently, putting the following code in a Jenkinsfile will raise a UnsupportedOperationException: Calling public static java.util.List org.codehaus.groovy.runtime.DefaultGroovyMethods.find(java.util.List,groovy.lang.Closure) on a CPS-transformed closure is not yet supported (JENKINS-26481); encapsulate in a @NonCPS method, or use Java-style loops

      node {
          tmp = [ 'A', 'B' ].find { it == 'B' }
          echo tmp
      }
      

      However, if this code is used without @NonCPS in a shared library, it will fail silently and tmp will be false.

            Unassigned Unassigned
            lucasc Lucas Cimon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: