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

git plugin always cleans workspace, even when instructed not to

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: git-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      Expected behavior: having "Wipe out workspace before build" unchecked would mean that the git plugin would not try to delete files in the workspace before building
      Actual behavior: having "Wipe out workspace before build" unchecked does not affect whether or not the git plugin tries to delete files in the workspace before building

      On version 1.5.0 of the git plugin (and judging by the source code, all versions since), the plugin unconditionally calls deleteContentsRecursive during the clone. This causes problems if the jenkins job running built any artifacts as another user, as they won't be able to be cleaned up. As there are checkboxes to indicate whether or not cleaning should occur, it seems like it would be nice to honor them.

      From src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java, line 366-370:

      try {
          Util.deleteContentsRecursive(workspace);
      } catch (Exception e) {
          e.printStackTrace(listener.error("Failed to clean the workspace"));
          throw new GitException("Failed to delete workspace", e);
      }
      

      When there are files not able to be deleted by jenkins, the following stacktrace is helpfully spewed:

      ERROR: Failed to clean the workspace
      java.nio.file.AccessDeniedException: <REDACTED>
      	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:244)
      	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
      	at java.nio.file.Files.delete(Files.java:1077)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at hudson.Util.deleteFile(Util.java:239)
      	at hudson.Util.deleteRecursive(Util.java:307)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:222)
      	at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:59)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:40)
      	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
      	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2444)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:744)
      ERROR: Error cloning remote repo 'origin' : Failed to delete workspace
      hudson.plugins.git.GitException: Failed to delete workspace
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:225)
      	at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:59)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:40)
      	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
      	at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2444)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:744)
      Caused by: java.nio.file.AccessDeniedException: <REDACTED>
      	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:244)
      	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
      	at java.nio.file.Files.delete(Files.java:1077)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at hudson.Util.deleteFile(Util.java:239)
      	at hudson.Util.deleteRecursive(Util.java:307)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at hudson.Util.deleteRecursive(Util.java:298)
      	at hudson.Util.deleteContentsRecursive(Util.java:204)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:222)
      	... 13 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ndeloof Nicolas De Loof
                Reporter:
                haus Matthaus Owens
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: