Using Jenkins 2.157 and SSH Slaves Plugin 1.29.4 I'm not able anymore to clean a Workspace.

      Running the following simplified Pipeline twice leads in an error:

      node("MySlave") {
          stage("doSomething") {
              deleteDir()
              sh "touch test"
          }
      }
      
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (doSomething)
      [Pipeline] deleteDir
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      jenkins.util.io.CompositeIOException: Unable to remove directory /home/ubuntu/jenkins-slave/workspace/TestPipeline with directory contents: [/home/ubuntu/jenkins-slave/workspace/TestPipeline/test]
      	at jenkins.util.io.PathRemover.removeOrMakeRemovableThenRemove(PathRemover.java:233)
      	at jenkins.util.io.PathRemover.tryRemoveFile(PathRemover.java:191)
      	at jenkins.util.io.PathRemover.forceRemoveFile(PathRemover.java:71)
      	at hudson.Util.deleteFile(Util.java:255)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1305)
      	at hudson.FilePath.access$1600(FilePath.java:213)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1274)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1270)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3086)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      java.nio.file.DirectoryNotEmptyException: /home/ubuntu/jenkins-slave/workspace/TestPipeline
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
      	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
      	at java.nio.file.Files.deleteIfExists(Files.java:1165)
      	at jenkins.util.io.PathRemover.removeOrMakeRemovableThenRemove(PathRemover.java:220)
      	at jenkins.util.io.PathRemover.tryRemoveFile(PathRemover.java:191)
      	at jenkins.util.io.PathRemover.forceRemoveFile(PathRemover.java:71)
      	at hudson.Util.deleteFile(Util.java:255)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1305)
      	at hudson.FilePath.access$1600(FilePath.java:213)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1274)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1270)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3086)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      java.nio.file.DirectoryNotEmptyException: /home/ubuntu/jenkins-slave/workspace/TestPipeline
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
      	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
      	at java.nio.file.Files.deleteIfExists(Files.java:1165)
      	at jenkins.util.io.PathRemover.removeOrMakeRemovableThenRemove(PathRemover.java:224)
      	at jenkins.util.io.PathRemover.tryRemoveFile(PathRemover.java:191)
      	at jenkins.util.io.PathRemover.forceRemoveFile(PathRemover.java:71)
      	at hudson.Util.deleteFile(Util.java:255)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1305)
      	at hudson.FilePath.access$1600(FilePath.java:213)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1274)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1270)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3086)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to MySlave
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
      		at hudson.remoting.Channel.call(Channel.java:957)
      		at hudson.FilePath.act(FilePath.java:1072)
      		at hudson.FilePath.act(FilePath.java:1061)
      		at hudson.FilePath.deleteRecursive(FilePath.java:1268)
      		at org.jenkinsci.plugins.workflow.steps.DeleteDirStep$Execution.run(DeleteDirStep.java:77)
      		at org.jenkinsci.plugins.workflow.steps.DeleteDirStep$Execution.run(DeleteDirStep.java:69)
      		at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:51)
      		at hudson.security.ACL.impersonate(ACL.java:290)
      		at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:48)
      		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      Caused: java.io.IOException: Unable to delete '/home/ubuntu/jenkins-slave/workspace/TestPipeline'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
      	at jenkins.util.io.PathRemover.forceRemoveFile(PathRemover.java:75)
      	at hudson.Util.deleteFile(Util.java:255)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1305)
      	at hudson.FilePath.access$1600(FilePath.java:213)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1274)
      	at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1270)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3086)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      

      Using Workspace Cleanup Plugin 0.37 works at least with test TestPipeline above, but I have a similar Error when checking out a Git Repo (containing a lot of subfolders).

          [JENKINS-55443] Unable to delete Workspace on SSH Slave with Pipeline

          A temporary workaround is it to perform "commandline" cleaning commands.

          e.g.

          node("MySlave") {
              stage("doSomething") {
                  sh "rm -rf *"
                  sh "touch test"
              }
          }
          

          Christoph Forster added a comment - A temporary workaround is it to perform "commandline" cleaning commands. e.g. node( "MySlave" ) { stage( "doSomething" ) { sh "rm -rf *" sh "touch test" } }

          It is not related to the ssh-slaves plugin, I changed the component to workflow-basic-steps where the deleteDir() step is defined. Workspace Cleanup plugin has nothing to be with deleteDir step, but in the past, there were issues related to interlocks with pipeline, try to disable the Workspace Cleanup plugin it it works you have the culprit.

          Ivan Fernandez Calvo added a comment - It is not related to the ssh-slaves plugin, I changed the component to workflow-basic-steps where the deleteDir() step is defined. Workspace Cleanup plugin has nothing to be with deleteDir step, but in the past, there were issues related to interlocks with pipeline, try to disable the Workspace Cleanup plugin it it works you have the culprit.

          Makson Lee added a comment -

          workspace cleanup plugin doesn't work in freestyle project now.

           

          jenkins: 2.157

          ssh slaves: 1.29.4

          workspace cleanup: 0.37

           

          Makson Lee added a comment - workspace cleanup plugin doesn't work in freestyle project now.   jenkins: 2.157 ssh slaves: 1.29.4 workspace cleanup: 0.37  

          I don't use freestyle project

          Christoph Forster added a comment - I don't use freestyle project

          Christoph Forster added a comment - - edited

          Using Jenkins 2.162 it seems to work now.
          Plugin Versions did not change

          Christoph Forster added a comment - - edited Using Jenkins 2.162 it seems to work now. Plugin Versions did not change

            Unassigned Unassigned
            forster_ch Christoph Forster
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: