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

PathRemover unable to delete folder with read only flag on Windows

XMLWordPrintable

    • 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);

       

       

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

              Created:
              Updated:
              Resolved: