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