Issue
We are having problems cleaning up the build workspace when using Git plugin in Windows nodes, this is happening the second time that we run the job on the same agent without restarting it.
-
Using the Workspace Cleanup plugin renders an error like the one shown below:
[WS-CLEANUP] Deleting project workspace... ERROR: [WS-CLEANUP] Cannot delete workspace: remote file operation faileX: X:\Folder\workspace\XXX\XXX at hudson.remoting.Channel@xxxxx:JNLP4-connect connection from XXX: java.nio.file.AccessDeniedException: X:\Folder\workspace\XXX\XXX -> X:\Folder\workspace\XXX\XXX_ws-cleanup_xxxx ERROR: Cannot delete workspace: remote file operation faileX: X:\Folder\workspace\XXX\XXX at hudson.remoting.Channel@xxxxx:JNLP4-connect connection from XXX: java.nio.file.AccessDeniedException: X:\Folder\workspace\XXX\XXX -> X:\Folder\workspace\XXX\XXX_ws-cleanup_xxxx
This will not work even if you exclude the files reported as blocked using excusions. image::common-kb::CE-3209-001.png[]
This kind of configuration will result on an error like the one shown below:
Wiping out workspace first. java.nio.file.FileSystemException: X:\Folder\workspace\XXX\XXX\.git\objects\pack\pack-xxxxxxxxxxx.pack: The process cannot access the file because it is being used by another process.
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees Jenkins Enterprise - Managed controller
Resolution
You need to add an additional behavior in the Git Plugin section that performs a Clean before checkout operation as shown below: image::common-kb::CE-3209-002.png[]
Workaround
-
An observed workaround if you want to keep using the Workspace Cleanup plugin is to restart the agent.