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

0 views
Skip to first unread message

m.winter@sap.com (JIRA)

unread,
Jun 5, 2019, 4:26:02 AM6/5/19
to jenkinsc...@googlegroups.com
Markus Winter created an issue
 
Jenkins / Bug JENKINS-57855
PathRemover unable to delete folder with read only flag on Windows
Issue Type: Bug Bug
Assignee: Unassigned
Components: core
Created: 2019-06-05 08:25
Environment: Jenkins 2.164.3
Priority: Blocker Blocker
Reporter: Markus Winter

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

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

m.winter@sap.com (JIRA)

unread,
Jun 5, 2019, 4:33:02 AM6/5/19
to jenkinsc...@googlegroups.com
Markus Winter updated an issue
Change By: Markus Winter
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\ 1bgf889vez 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 soluition solution is to use

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

 

 

dbeck@cloudbees.com (JIRA)

unread,
Jun 13, 2019, 2:37:02 PM6/13/19
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
Jun 24, 2019, 4:21:02 AM6/24/19
to jenkinsc...@googlegroups.com
Daniel Beck resolved as Fixed
Change By: Daniel Beck
Status: Open Resolved
Resolution: Fixed
Released As: jenkins-2.182

m.winter@sap.com (JIRA)

unread,
Jun 24, 2019, 4:46:01 AM6/24/19
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
Sep 5, 2019, 5:54:08 AM9/5/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages