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

PathRemover unable to delete folder with read only flag on Windows

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Jenkins 2.164.3
    • Similar Issues:
    • Released As:
      jenkins-2.182

      Description

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

       

       

        Attachments

          Issue Links

            Activity

            mawinter69 Markus Winter created issue -
            mawinter69 Markus Winter made changes -
            Field Original Value New Value
            Description 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);_

             

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

             

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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: