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

.eachDir() iterate only once

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      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

        Attachments

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              Assignee:
              oleg_nenashev Oleg Nenashev
              Reporter:
              majkl20 Michal Schindler
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: