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

Cleanup workspace when last build is >X days ago

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • core

      We have a Jenkins install with lots of different jobs, most of them are triggered by SCM changes. In addition to be able to prune old builds, it would be desirable to be able to clean up the workspace if the last build was more than a specified number of days ago.

          [JENKINS-21322] Cleanup workspace when last build is >X days ago

          Anders Hammar added a comment -

          I don't really understand the use case here. Are you saying that you would like the workspace to be cleaned if the last build was, for example, more than 2 days ago? So then if there is at least one build every day, the workspace is never cleaned?

          The use case I have is that I want the workspace to be cleaned every day, but not more than once per day.

          Anders Hammar added a comment - I don't really understand the use case here. Are you saying that you would like the workspace to be cleaned if the last build was, for example, more than 2 days ago? So then if there is at least one build every day, the workspace is never cleaned? The use case I have is that I want the workspace to be cleaned every day, but not more than once per day.

          Daniel Beck added a comment -

          This request appears to be a a very limited use case.

          Daniel Beck added a comment - This request appears to be a a very limited use case.

          Lieuwe Hummel added a comment -

          My use case is that we have a fair amount of projects. For the day-to-day code analysis and builds, we leave the workspace as is. But I would like to see this feature as a cleanup tool: keep the jobs related to the project, but clear the workspace to preserve diskspace after, say, 60 days or so.
          But a scheduled cleanup of the workspace would solve my case for some fair part i think,

          Lieuwe Hummel added a comment - My use case is that we have a fair amount of projects. For the day-to-day code analysis and builds, we leave the workspace as is. But I would like to see this feature as a cleanup tool: keep the jobs related to the project, but clear the workspace to preserve diskspace after, say, 60 days or so. But a scheduled cleanup of the workspace would solve my case for some fair part i think,

          Daniel Beck added a comment -

          clear the workspace to preserve diskspace after, say, 60 days or so.

          Something like this is a Jenkins core feature. Set up a log recorder for the logger hudson.model.WorkspaceCleanupThread in /log to see what it's doing.

          Daniel Beck added a comment - clear the workspace to preserve diskspace after, say, 60 days or so. Something like this is a Jenkins core feature. Set up a log recorder for the logger hudson.model.WorkspaceCleanupThread in /log to see what it's doing.

          Lieuwe Hummel added a comment -

          Thanks, did not known about that yet, I'll give it a try

          Lieuwe Hummel added a comment - Thanks, did not known about that yet, I'll give it a try

          Moving this to core (as that is where hudson.model.WorkspaceCleanupThread currently resides). Though, the reoccurrence period nor the maximal workspace age can not be configured as requested.

          Oliver Gondža added a comment - Moving this to core (as that is where hudson.model.WorkspaceCleanupThread currently resides). Though, the reoccurrence period nor the maximal workspace age can not be configured as requested.

          Oliver Gondža added a comment - https://github.com/jenkinsci/jenkins/pull/1638

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/model/WorkspaceCleanupThread.java
          test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java
          http://jenkins-ci.org/commit/jenkins/825b04103c6ba2777a672d3811a5c0103540fd49
          Log:
          [FIXED JENKINS-21322] Make maximal workspace age configurable

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/model/WorkspaceCleanupThread.java test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java http://jenkins-ci.org/commit/jenkins/825b04103c6ba2777a672d3811a5c0103540fd49 Log: [FIXED JENKINS-21322] Make maximal workspace age configurable

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          core/src/main/java/hudson/model/WorkspaceCleanupThread.java
          test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java
          http://jenkins-ci.org/commit/jenkins/a803dc1f852fdf5d8add03b8fdca624c6a7ab9ee
          Log:
          Merge pull request #1638 from olivergondza/configure-periodic-ws-cleanup

          [FIXED JENKINS-21322] Configure periodic ws cleanup

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: core/src/main/java/hudson/model/WorkspaceCleanupThread.java test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java http://jenkins-ci.org/commit/jenkins/a803dc1f852fdf5d8add03b8fdca624c6a7ab9ee Log: Merge pull request #1638 from olivergondza/configure-periodic-ws-cleanup [FIXED JENKINS-21322] Configure periodic ws cleanup

          dogfood added a comment -

          Integrated in jenkins_main_trunk #4065

          Result = SUCCESS

          dogfood added a comment - Integrated in jenkins_main_trunk #4065 Result = SUCCESS

          Code changed in jenkins
          User: Daniel Beck
          Path:
          changelog.html
          http://jenkins-ci.org/commit/jenkins/fec557818c79f8465d3ce73224d51d7f9598f2c2
          Log:
          Improve changelog entry for JENKINS-21322

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: changelog.html http://jenkins-ci.org/commit/jenkins/fec557818c79f8465d3ce73224d51d7f9598f2c2 Log: Improve changelog entry for JENKINS-21322

          arthur m added a comment -

          Hi,

          This ticket seems to implement exactly what I need, however I can't find how to turn it on in the Jenkins config. Is there anyone that could kindly point me to the proper page?

          Thanks,

          Arthur

          arthur m added a comment - Hi, This ticket seems to implement exactly what I need, however I can't find how to turn it on in the Jenkins config. Is there anyone that could kindly point me to the proper page? Thanks, Arthur

          arthurplma, see hudson.model.WorkspaceCleanupThread.recurrencePeriodHours and hudson.model.WorkspaceCleanupThread.retainForDays at https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties

          Oliver Gondža added a comment - arthurplma , see hudson.model.WorkspaceCleanupThread.recurrencePeriodHours and hudson.model.WorkspaceCleanupThread.retainForDays at https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties

          arthur m added a comment -

          Thanks Oliver

           

          arthur m added a comment - Thanks Oliver  

            olivergondza Oliver Gondža
            lurkie Lieuwe Hummel
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: