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

PathRemover unable to delete folder with read only flag on Windows

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None
    • Jenkins 2.164.3
    • jenkins-2.182

      Since updating to Jenkins core to 2.164.3 we run into issues that builds running on windows agents were not able do delete certain folders when checking out with git.

      We always get an access denied:
      **

      16:53:25 java.nio.file.AccessDeniedException: d:\701\w\project\cache\dependencies\clients\ant-1.9.4-bin\bin
      16:53:25 	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
      16:53:25 	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
      16:53:25 	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
      16:53:25 	at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
      16:53:25 	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
      16:53:25 	at java.nio.file.Files.deleteIfExists(Files.java:1165)
      16:53:25 	at jenkins.util.io.PathRemover.removeOrMakeRemovableThenRemove(PathRemover.java:233)
       

      Trying a rd <folder> on the command line shows the same problem.

       

      But rd /s <folder> works.

      After analysis we found the problem is that some build process creates folders that have the read only flag set.

       

      D:\>attrib d:\701\w\project\cache\dependencies\clients\ant-1.9.4-bin\bin
       R    d:\701\w\project\cache\dependencies\clients\ant-1.9.4-bin\bin
      

      The PathRemover tries to resolve this by calling

      path.toFile().setWritable(true);

      on each file/folder it can't delete initially.

      But this method will not remove the read only flag on a windows folder.

      The solution is to use

      Files.setAttribute(path, "dos:readonly", false);

       

       

          [JENKINS-57855] PathRemover unable to delete folder with read only flag on Windows

          Markus Winter created issue -
          Markus Winter made changes -
          Description Original: Since updating to Jenkins core to 2.164.3 we run into issues that builds running on windows agents were not able do delete certain folders when checking out with git.

          We always get an access denied:
          *16:53:25* java.nio.file.AccessDeniedException: d:\701\w\1bgf889vez\cache\dependencies\clients\ant-1.9.4-bin\bin*16:53:25* at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)*16:53:25* at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)*16:53:25* at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)*16:53:25* at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)*16:53:25* at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)*16:53:25* at java.nio.file.Files.deleteIfExists(Files.java:1165)*16:53:25* at jenkins.util.io.PathRemover.removeOrMakeRemovableThenRemove(PathRemover.java:233)
          Trying a _rd <folder>_ on the command line shows the same problem.

          But _rd /s <folder>_ works.

          After analysis we found the problem is that some build process creates folders that have the read only flag set.

          The PathRemover tries to resolve this by calling

          _path.toFile().setWritable(true);_

          on each file/folder it can't delete initially.

          But this method will not remove the read only flag on a windows folder.

          The soluition is to use

          _Files.setAttribute(path, "dos:readonly", false);_

           

           
          New: Since updating to Jenkins core to 2.164.3 we run into issues that builds running on windows agents were not able do delete certain folders when checking out with git.

          We always get an access denied:
           **
          {code:java}
          16:53:25 java.nio.file.AccessDeniedException: d:\701\w\project\cache\dependencies\clients\ant-1.9.4-bin\bin
          16:53:25 at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
          16:53:25 at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
          16:53:25 at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
          16:53:25 at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
          16:53:25 at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
          16:53:25 at java.nio.file.Files.deleteIfExists(Files.java:1165)
          16:53:25 at jenkins.util.io.PathRemover.removeOrMakeRemovableThenRemove(PathRemover.java:233)
           {code}
          Trying a _rd <folder>_ on the command line shows the same problem.

           

          But _rd /s <folder>_ works.

          After analysis we found the problem is that some build process creates folders that have the read only flag set.

           
          {code:java}
          D:\>attrib d:\701\w\project\cache\dependencies\clients\ant-1.9.4-bin\bin
           R d:\701\w\project\cache\dependencies\clients\ant-1.9.4-bin\bin
          {code}
          The PathRemover tries to resolve this by calling

          _path.toFile().setWritable(true);_

          on each file/folder it can't delete initially.

          But this method will not remove the read only flag on a windows folder.

          The solution is to use

          _Files.setAttribute(path, "dos:readonly", false);_

           

           
          Daniel Beck made changes -
          Priority Original: Blocker [ 1 ] New: Minor [ 4 ]
          Daniel Beck made changes -
          Released As New: jenkins-2.182
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Markus Winter made changes -
          Labels New: lts-candidate
          Daniel Beck made changes -
          Remote Link New: This issue links to "PR 4059 (Web Link)" [ 23529 ]
          Daniel Beck made changes -
          Labels Original: lts-candidate

            Unassigned Unassigned
            mawinter69 Markus Winter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: