.eachDir() iterate only once

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major
    • Component/s: pipeline
    • Environment:

      I am trying to do a simple housekeeping pipeline to delete old workspace dirs within Jenkins.

      node {
      stage 'Housekeeping stage'
      echo "Deleting all old cell directories, older then ${env.MAXIMUM_CELL_LIVE} days"
      new File("${env.phaser_dir}\\workspace
      ").eachDir() { dir ->
      long diff = new Date().getTime() - dir.lastModified()
      if (diff > env.MAXIMUM_CELL_LIVE.toInteger() * 24 * 60 * 60 * 1000)

      { dir.deleteDir() }

      }
      }
      The result is that it iterates only once each time, deleting just one directory.

      I have latest version of Pipeline at 2.2. I've also googled there used to be problems like this with .each iterator, but that supposed to be fixed?

      Many Thanks Michal

            Assignee:
            Oleg Nenashev
            Reporter:
            Michal Schindler
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: