Cannot delete workspace

1,628 views
Skip to first unread message

John Gregg

unread,
Jul 13, 2018, 4:38:32 PM7/13/18
to Jenkins Users
All,

I have Jenkins 2.121.1.

I get this error when my job tries to delete the workspace:

Started by remote host 127.0.0.1
Building in workspace C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace
[WS-CLEANUP] Deleting project workspace...
ERROR: [WS-CLEANUP] Cannot delete workspace: C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace -> C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace_ws-cleanup_1531512476552
ERROR: Cannot delete workspace: C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace -> C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace_ws-cleanup_1531512476552

In addition, Tomcat prints this stack trace:

13-Jul-2018 15:07:56.552 SEVERE [Executor #0 for master : executing Taurus #62] hudson.plugins.ws_cleanup.PreBuildCleanup.preCheckout Cannot delete workspace
java.nio.file.AccessDeniedException: C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace -> C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace_ws-cleanup_1531512476552
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387)
at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
at java.nio.file.Files.move(Files.java:1395)
at hudson.FilePath$28.invoke(FilePath.java:2085)
at hudson.FilePath$28.invoke(FilePath.java:2082)
at hudson.FilePath.act(FilePath.java:1047)
at hudson.FilePath.act(FilePath.java:1025)
at hudson.FilePath.renameTo(FilePath.java:2082)
at hudson.plugins.ws_cleanup.Wipeout.perform(Wipeout.java:63)
at hudson.plugins.ws_cleanup.PreBuildCleanup.preCheckout(PreBuildCleanup.java:94)
at jenkins.scm.SCMCheckoutStrategy.preCheckout(SCMCheckoutStrategy.java:76)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:498)
at hudson.model.Run.execute(Run.java:1794)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)

Jenkins is running under Tomcat started by me, so I can't understand why there could be an AccessDeniedException. The Jenkins workspace is under my home directory.

I get the same error whether I try to delete the workspace at the start or end of my job.

thanks

John

John Mellor

unread,
Jul 13, 2018, 4:56:08 PM7/13/18
to jenkins...@googlegroups.com
I get into this problem all the time, generally due to no permission in part of the tree inside the workspace.  Most generally, I find this tends to happen when building Docker images in Linux and the workspace volume mount internals are all owned by root instead of Jenkins.

All of the Jenkins workspace deletion mechanisms need to be fixed to work in spite of permission issues. As a workaround, maybe you can coerce the build owner to modify their build to add world-everything permissions to the entire workspace...

Mark Waite

unread,
Jul 13, 2018, 5:20:44 PM7/13/18
to jenkins...@googlegroups.com
On Fri, Jul 13, 2018 at 2:38 PM John Gregg <goo...@johngregg.org> wrote:
All,

I have Jenkins 2.121.1.

I get this error when my job tries to delete the workspace:

Started by remote host 127.0.0.1
Building in workspace C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace
[WS-CLEANUP] Deleting project workspace...
ERROR: [WS-CLEANUP] Cannot delete workspace: C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace -> C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace_ws-cleanup_1531512476552
ERROR: Cannot delete workspace: C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace -> C:\Users\John.E.Gregg\.jenkins\jobs\Taurus\workspace_ws-cleanup_1531512476552

The Windows file system will not allow a file be deleted which is held open by a process.  If a file is held open by a process, then the directory which contains that file also cannot be deleted.

I would guess that some process (probably Jenkins) has a file open in that workspace and so the workspace cannot be deleted.

Unix based file systems will allow a file to be deleted which is held open by a process.  Unix based Jenkins servers don't see this type of problem typically.

They may see problems (as mentioned by John Mellor) when file or directory permissions forbid delete.  I suspect that is not the case you're seeing here.

My preference has been to run my Jenkins server on Linux (as a Docker image) with Windows agents.  Your needs may require something different, but Linux has been a happier place to run a Jenkins server for me.

Mark Waite
 
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/341bface-8864-4cbf-bdd6-5cb89a08dc60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages