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

Delete workspaces when deleting a job

    XMLWordPrintable

Details

    Description

      When working with many short-lived feature branches, Jenkins can start to eat up a lot of disk space by leaving old workspaces around from old builds.

      This seems to be especially true with the Pipeline Multibranch Plugin. When that plugin deletes the job for a branch when the branch is deleted, it should simultaneously clean up any of the workspaces created for that branch job (e.g. "feature-foo", "feature-foo@2", "feature-foo@3", etc).

      Attachments

        Issue Links

          Activity

            YES! Actually I want to limit a multi-branch pipeline to only keep the 3 most used branches around (like master, and two currently used feature branches).

            A "Number of most frequently used branches to keep" setting would be awesome IMO.

            cobexer Ing. Christoph Obexer added a comment - YES! Actually I want to limit a multi-branch pipeline to only keep the 3 most used branches around (like master, and two currently used feature branches). A "Number of most frequently used branches to keep" setting would be awesome IMO.

            Would be nice to have a configurable trigger "onBranchDelete" to execute custom cleaning scripts like the "Post-build Actions" in normal jobs.

            In my workflow, I'm deploying feature branches code and database to a testing environment which should be cleaned once the feature branches have been merged and deleted.

            vmwiz Gilles Nedostoupof added a comment - Would be nice to have a configurable trigger "onBranchDelete" to execute custom cleaning scripts like the "Post-build Actions" in normal jobs. In my workflow, I'm deploying feature branches code and database to a testing environment which should be cleaned once the feature branches have been merged and deleted.
            shakefu Jake Alheid added a comment -

            We have a large, multi-gigabyte repository, and this bug is repeatedly causing us to either have to go in and manually clean out old branches, or giving test failures because hundreds of gigabytes of space are being taken up in a short time due to the multiple checkouts.

            Please fix!

            shakefu Jake Alheid added a comment - We have a large, multi-gigabyte repository, and this bug is repeatedly causing us to either have to go in and manually clean out old branches, or giving test failures because hundreds of gigabytes of space are being taken up in a short time due to the multiple checkouts. Please fix!

            We are also experiencing this. It seems to cause issues at the most inconvenient time. (Of course when would it ever be convenient). We have temporarily set up a very conservative cron style jenkins job to clean out the jobs in the wee hours of the morning, but that could potentially cause problems down the line. Would like to keep the cleanup in house on a per job basis.

            nickj Nicholas Bencriscutto added a comment - We are also experiencing this. It seems to cause issues at the most inconvenient time. (Of course when would it ever be convenient). We have temporarily set up a very conservative cron style jenkins job to clean out the jobs in the wee hours of the morning, but that could potentially cause problems down the line. Would like to keep the cleanup in house on a per job basis.
            jglick Jesse Glick added a comment -

            I think this is actually a more general core issue: Job.delete (or some associated ItemListener.onDeleted should proactively delete any associated workspaces it can find on any connected nodes. WorkspaceCleanupThread as currently implemented is not going to find them.

            jglick Jesse Glick added a comment - I think this is actually a more general core issue: Job.delete (or some associated ItemListener.onDeleted should proactively delete any associated workspaces it can find on any connected nodes. WorkspaceCleanupThread as currently implemented is not going to find them.
            jglick Jesse Glick added a comment -

            JENKINS-22240 is very similar; probably both could and should be fixed together.

            jglick Jesse Glick added a comment - JENKINS-22240 is very similar; probably both could and should be fixed together.

            People

              Unassigned Unassigned
              pioto Mike Kelly
              Votes:
              7 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: