Since upgrading to Pipeline:Groovy 2.48, the .empty property of List objects gives very strange results, whose boolean value in particular is the reverse of the expected.

      When executing the following script as a pipeline (testet via "Replay" and replacing the existing script by this) gives weird output:

       Script

      x = [] as List
      println x
      println x.isEmpty()
      println x.empty
      x<<"hello"
      println x
      println x.isEmpty()
      println x.empty
      

      Expected output

      [Pipeline] echo
      []
      [Pipeline] echo
      true
      [Pipeline] echo
      true
      [Pipeline] echo
      [hello]
      [Pipeline] echo
      false
      [Pipeline] echo
      false
      [Pipeline] End of Pipeline
      

      Actual output

      [Pipeline] echo
      []
      [Pipeline] echo
      true
      [Pipeline] echo
      []
      [Pipeline] echo
      [hello]
      [Pipeline] echo
      false
      [Pipeline] echo
      [false]
      [Pipeline] End of Pipeline
      

      Downgrading the Pipeline:Groovy plugin to 2.47 fixes it; after upgrading again, the weird behaviour is back.

      Workaround

      For the moment, I can live with calling isEmpty() instead of accessing empty.

      further considerations

      I have not tested whether any other properties besides .empty are affected.

          [JENKINS-50863] list.empty broken in pipeline scripts

          Hans-Jakob Holtz created issue -
          Andrew Bayer made changes -
          Labels Original: regression New: complex-cps-code regression triaged-2018-11

            Unassigned Unassigned
            hjholtz Hans-Jakob Holtz
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: