Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Plugin Information

View Workspace Cleanup on the plugin site for more information.

Plugin to delete the build workspace.


The plugin declared build wrapper (Delete workspace before build starts) and post build step (Delete workspace when build is done). They both permit configuring what and in what circumstances will be deleted. The post build step can also take into account the build status.

Files to be deleted are specified by pattern using Ant syntax. Pattern is typed into field (1). In select box (2) you can choose if the pattern is include pattern (if the file matches this pattern, file will be removed) or exclude pattern (if file matches this pattern, file won't be removed). If there is only exclude pattern, as include pattern will be used "*/", i.e. delete everything, which means that everything will be deleted except files matching exclude pattern. Patterns are applied only on files. If you want to apply them also on directories, check checkbox (3). Please note, that directory is deleted with all content, so if the directory matches include pattern, everything in this dir will be deleted no matter if some files in this dir matches exclude pattern.

Example of the patterns (taken from DirectoryScanner javadoc, for detail see javadoc):

**/*.class		// matches all .class files/dirs in a directory tree.
test/a??.java	// matches all files/dirs which start with an 'a', then two more characters and then ".java", in a directory called test.
**				// matches everything in a directory tree.
**/test/**/XYZ* // matches all files/dirs which start with "XYZ" and where there is a parent directory called test (e.g. "abc/test/def/ghi/XYZ123").

When whole workspace is supposed to be deleted (no patterns, external commands, etc.), the plugin delegate to the Resource Disposer Plugin to speed things up.

Disable deferred wipeout method

In particular deployment (e.g. cloud) it might be useful to be sure deferred wipeout is never selected as a cleanup method. Therefore there is a new feature introduced to do this, implemented via regular NodeProperty which you can attach to any node via UI or via script like:

Node.getNodeProperties().add(new DisableDeferredWipeoutNodeProperty());

When deferred wipeout is disabled the old implementation of filesystem content deletion is used. If you want the same behavior as with deferred wipeout, you have to set plugin attribute deleteDirs to true as well. In pipeline job's script, you can do that like:

cleanWs disableDeferredWipeout: true, deleteDirs: true


Release 0.37 (2018-12-17)
  • Java 11 support was introduced in this release. Older versions does not support it.
Release 0.35 (2018-10-11)
  • Introduce a way how to disable deferred Wipeout (PR#37 JENKINS-53740 - Getting issue details... STATUS )
Release 0.34 (2017-07-17)
  • Avoid using stale channel in disposable what node goes offline (PR #33)
Release 0.33 (2017-04-24)
  • Add pipeline friendly syntax (PR #30)
  • Japanese localization (PR #32)

  • Fix inclusion/exclusion pattern layout ( JENKINS-43179 - Getting issue details... STATUS )
Release 0.32 (2016-11-01)
  • Do not leak temporary directories that plugin failed to clean (JENKINS-24824)
Release 0.30 (2016-06-24)
  • Pipeline support
Release 0.27 (2015-08-19)
  • Adjusted console logging
  • Added logging to track down JENKINS-24824
Release 0.26 (2015-05-29)
  • Require minimal width for pattern labels (JENKINS-27103)
  • Do not log exceptions on stderr
Release 0.25 (2015-01-25)
  • Survives workspace rename failure during async delete (JENKINS-26250)
Release 0.24 (2014-09-09)
Release 0.23 (2014-08-26)
Release 0.22 (2014-08-03)
  • Fixed env. var. expansion on nodes
Release 0.21 (2014-06-23)
Release 0.20 (2014-02-01)
  • Fixed build status setting - if the workspace cleanup fails, build status is set to FAILURE (pull #14)
Release 0.19 (2013-10-08)
  • Fixed problem with spaces in external cleanup command (pull #13)
Release 0.18 (2013-09-15)
  • Fixed broken backward compatibility in pre-build cleanup (JENKINS-19574)
Release 0.17 (2013-09-11)
  • Allow to configure external program to do the cleanup (pull #12)
  • Fixed German translation encoding (pull #11)
Release 0.16 (2013-07-02)
  • Added ability to specify if the workspace should be wiped out in pre-build step via a job parameter (pull #10)
Release 0.15 (2013-06-18)
  • Don't wait for previous build step to complete (pull #9)
Release 0.14 (2013-05-14)
Release 0.13 (2013-05-03) 
  • Configure deleting of workspace based on build status (pull #7)
  • German translation (pull #6)
Release 0.12 (2013-02-16) 
  • Retry delete 3 times in prebuild cleanup and add eventually error message into console log (pull #5)
Release 0.11 (2013-01-23) 
  • Added option not to fail the build if some error happens during the cleanup (JENKINS-15236)
  • Added option to cleanup matrix parent workspace (JENKINS-14128)
Release 0.10 (2012-07-17) 
  • Fixed skipping the cleanup - skip only when this option is checked (pull #4)
Release 0.9 (2012-07-15) 
  • Added option to skip the cleanup when build fails (pull #3)
Release 0.8 (2012-03-14) 
  • Ensure, that ws cleanup is run after all other plugins (JENKINS-12962)
Release 0.7 (2011-12-07) 
  • Check if workspace exists (JENKINS-11998)
  • Added possibility to delete also directories when delete pattern is specified (JENKINS-11927)
  • Added possibility to specify also exclude patterns (JENKINS-11928)
  • Added missing Pattern descriptor
Release 0.6 (2011-10-11)
  • Ws clean up should be the first or the last step in case of pre-build or post-build cleanup, respectively (JENKINS-11210)
Release 0.5 (2011-09-27)
  • Added possibility to delete only part of the workspace specified by ant dir scanner pattern.
Release 0.4 (2011-04-07)
  • Bug fix - checkbox for deleting workspace after the build was not showing up on the job config page 
Release 0.3 (2011-03-02)
  • Fix to delete right workspace when "concurrent builds" option is in use
Release 0.2 (2011-02-28)
  • Add an option to delete workspace before build (requires Jenkins 1.399 or higher)
Release 0.1 (2011-02-10)
  • Initial release


  1. Unknown User (brucezu)

    I can not find the config option on job config page . will you please provide a related snapshot?

  2. Unknown User (miked)

    i think you should change the description of the plugin to mention that cleaning up the workspace before the build is also an option

  3. Unknown User (xter)


    I'm trying to use your new feature to delete only part of the workspace specified by ant pattern but it does not work...

    May be I have used a bad pattern so could you give me an example ?

    My goal is to delete only the target folders into the workspace for each modules and sub-modules.


    1. Unknown User (cecom)

      i had the same problem and had a look in the plugin. the plugin is looking only for files, not for directories. i added a feature request 11927.

  4. Hello,

    i am running Jenkins 1.449 and installed the ws-cleanup plugin. After the installation i noticed that version 0.4 has been installed, no chance to update via the gui.

    Is there any reason why jenkins did not install the latest released version (i'd like to use the additional features from versions 0.5 + 0.6) ?

    Is there a way to install the jpi manually ?

    tia, Oliva

  5. Unknown User (cmatta)

    Am I crazy or is there no delete button for this plugin's step? After adding it to my project I wanted to remove the step, but I can't figure out how.

  6. Unknown User (vignesh89)

    We have an option in Jenkins Job configuration page 'Clean Workspace before each build' which almost does the same job as of this plug-in apart from selectively removing the files or folders,

    Is my understanding correct , if not pls. correct me.. I would like to implement this plug-in my local Jenkins to clear up the workspace after/before each build.

    A clarification b/n the above two features will be of much help.

    Thanks in advance !

  7. Unknown User (loyopp)

    how to add this plugin to Jenkins ?

  8. Unknown User (mako)

    I've tried to delete all files in target folder by mask (target/.) but it doesn't work on Debian slave at least

    Deleting project workspace... Using command: /home/myproject/jenkins/workspace/Upload - myprogram (Win7)/target/111.txt
    Using command: /home/myproject/jenkins/workspace/Upload - myprogram (Win7)/target/111.txt
    Using command: /home/myproject/jenkins/workspace/Upload - myprogram (Win7)/target/111.txt
    Cannot delete workspace: java.io.IOException: Cannot run program "/home/myproject/jenkins/workspace/Upload": error=2, No such file or directory
    ERROR: Cannot delete workspace: java.io.IOException: Cannot run program "/home/myproject/jenkins/workspace/Upload": error=2, No such file or directory

    However it deletes whole workspace without such problem.

  9. Unknown User (nicolasperrier)

    The feature is not respecting symbolic links as they would be under unix if 'rm' command were used.

    I would expect the delete pattern to follow the behavior as if it were behind a unix 'rm' command.

    My workspace contains 1 symlink to a folder (with stuff in it, call this stuff_1) and 1 folder (with stuff in it, call this stuff_2)

    The pattern I enter is */*

    I enable the option to delete directories.

    I would expect that to behave the same as "rm -r */*"

    In a Unix/Linux environment, this would preserve the symlink as well as the folder, and it would destroy stuff_1 and stuff_2 (well, everything thats not a hidden folder starting with a '.')

    Instead, the symbolic link gets destroyed.  The directory does get preserved.

    I believe its a bug that the symbolic link gets destroyed.

  10. Unknown User (amoss)

    The changelog for 0.24 on 2014-09-09 above appear as a second set of changes for 0.23

    1. Unknown User (scoheb)

      Updated and sent email to maintainers.

  11. Unknown User (pitargue)

    With Jenkins version 1.595, Workspace Cleanup Plugin version 0.24, and docker plugin 0.8, the clean after build is not completing.  Either getting a partial remove or none at all, possibly because the container is stopped before the clean finishes.  Any ideas?

  12. Unknown User (arpitgupta)

    Hi i have been using this plugin as a post build action but ran into an issue where i need to control the order in which post build actions are run. Assuming the order they appear in the UI is the order in which the delete workspace shows up is the order in which the plugin will be executed did not work. In bug https://issues.jenkins-ci.org/browse/JENKINS-27852 it was mentioned that "The implementation type of post-build steps classifies them as one of three or so groups that are executed in that order. This overrides any UI order specified.". 

    So i was curious is that expected that the delete runs even though its defined last or do we have a bug?

  13. Unknown User (rusticcajun)

    I'm stuck on the "Check parameter" field to determine whether to perform a pre-build workspace deletion.  I entered VARIABLE, and in the Manage Jenkins -> Configuration, I added a Global property name = VARIABLE, value = true.   This isn't sufficient to delete the workspace.  How should it work?  Thanks!

    1. Unknown User (samapico)

      It works for me using the Parametrized Build plugin. I don't know if/how it can be integrated with global properties.

  14. Unknown User (stammt)

    I'd like to see an option to only clean up a workspace if the project hasn't been updated in the last days / weeks / months. Is that something you might consider?

    1. Unknown User (cbennett)

      It would be great to have some more flexible control.  I manage a server with hundreds of jobs, and it's not feasible to always delete workspaces after builds, for two main reasons:

      1. Git repositories will have to completely re-downloaded on each build.

      2. Having full workspace available for recent builds is helpful for debugging the build or obtaining other output files that might not have been archived as artifacts (yes, I do forget to archive important output files sometimes).

      Possibly some kind of scheduled cleanup process, such as removing workspaces of jobs whose last build is at least X days ago, etc.

  15. Unknown User (ophyte)

    I'm trying to delete my whole angularjs workspace except the directory "node_modules" which is very long to update but none of my patterns tested seems to work !?!

    I tried the following exclude patterns with the "Apply pattern also on directories" option checked :

    • node_modules
    • ./node_modules
    • **/node_modules/
    • node_modules/
    • **/node/**

    Surprisingly, when I try with another directory called "tools", it works fine with the first pattern of the list above !!! 

  16. Unknown User (chellisage)

    Hi, I'm having a problem with the plugin removing the entire workspace if the previous job fails.  I have the following:

    * Delete workspace on new build - checked

    Exclude  emailable-report*.html

    Everything works fine, as long as the previous job doesn't fail, if it fails, the next run deletes the entire workspace.  I've tried the following excludes and my files just aren't saved:

    - Exclude emailable-report*.html

    - Exclude /test-output/emailable-report*.html

    - Exclude test-output/emailable-report*.html

    - Exclude ${WORKSPACE}/test-output/emailable-report.html

    Please help me figure out how to exclude these files, and not have the entire workspace blown away after a failed job.

    UPDATE: now it's even deleting everything on successes. I'm so confused.

  17. Unknown User (bahdad)

    What's new in version 0.33 and 0.34?

  18. Unknown User (rickybobpat)

    HI.  Changelog on this page does not show descriptions of changes for .33 and .34 versions.

  19. Unknown User (ishan_12)

    I tried the GitHub way: 

    → https://github.com/jenkinsci/ws-cleanup-plugin/commits/ws-cleanup-0.33
    → https://github.com/jenkinsci/ws-cleanup-plugin/commits/ws-cleanup-0.34 

    Seems like they added something called avoid accept which I have no clue what that is. 



  20. Unknown User (ishan_12)

    One of the issue that I wanted to report is that in pipeline, let's say you add a file and give it root permissions. After that I added sudo rm -rf in workspace cleanup as below:
    cleanWs externalDelete: 'sudo rm -rf *'
    However, this doesn't seem to work. This is also behind the finally block so technically it should always execute. Oddly, this only happens while using pipeline i.e. regular non-pipeline job works just fine.
    Anybody else facing similar issue? 
  21. Unknown User (ursaslam)

    I couldn't install this plugin in Jenkins. I was keep on getting Socket time out issue and below are the error details

    Durable Task Plugin
     Failure -
    java.net.SocketTimeoutException: connect timed out
    	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    	at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    	at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    	at java.net.PlainSocketImpl.connect(Unknown Source)
    	at java.net.SocksSocketImpl.connect(Unknown Source)
    	at java.net.Socket.connect(Unknown Source)
    	at sun.net.NetworkClient.doConnect(Unknown Source)
    	at sun.net.www.http.HttpClient.openServer(Unknown Source)
    	at sun.net.www.http.HttpClient.openServer(Unknown Source)
    	at sun.net.www.http.HttpClient.<init>(Unknown Source)
    	at sun.net.www.http.HttpClient.New(Unknown Source)
    	at sun.net.www.http.HttpClient.New(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
    	at java.net.URLConnection.getHeaderFieldLong(Unknown Source)
    	at java.net.URLConnection.getContentLengthLong(Unknown Source)
    	at java.net.URLConnection.getContentLength(Unknown Source)
    	at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1126)
    Caused: java.net.SocketTimeoutException: connect timed out
    Caused: java.io.IOException: Failed to load http://updates.jenkins-ci.org/download/plugins/durable-task/1.14/durable-task.hpi to C:\Program Files (x86)\Jenkins\plugins\durable-task.jpi.tmp
    	at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1146)
    Caused: hudson.util.IOException2: Failed to download from http://updates.jenkins-ci.org/download/plugins/durable-task/1.14/durable-task.hpi
    	at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1172)
    	at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1677)
    	at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1874)
    	at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1651)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    	at java.util.concurrent.FutureTask.run(Unknown Source)
    	at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
    	at java.lang.Thread.run(Unknown Source)