Java.nio.file.DirectoryNotEmptyException when removing lastSuccessful / lastStable jenkins

when the jenkins job starts, the console reports this error:

java.nio.file.DirectoryNotEmptyException: C:\jenkins\jobs\My Job\lastSuccessful at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source) at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source) at java.nio.file.Files.deleteIfExists(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at hudson.Util.createSymlinkJava7(Util.java:1194) at hudson.Util.createSymlink(Util.java:1112) at hudson.model.Run.createSymlink(Run.java:1846) at hudson.model.Run.updateSymlinks(Run.java:1827) at hudson.model.Run.execute(Run.java:1738) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) ln builds\lastStableBuild C:\jenkins\jobs\My Job\lastStable failed java.nio.file.DirectoryNotEmptyException: C:\jenkins\jobs\My Job\lastStable at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source) at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source) at java.nio.file.Files.deleteIfExists(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at hudson.Util.createSymlinkJava7(Util.java:1194) at hudson.Util.createSymlink(Util.java:1112) at hudson.model.Run.createSymlink(Run.java:1846) at hudson.model.Run.updateSymlinks(Run.java:1828) at hudson.model.Run.execute(Run.java:1738) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) 

Is this a bug or something I need to fix?

+5
source share
2 answers

Your problem is in bugtracker Jenkins: https://issues.jenkins-ci.org/browse/JENKINS-21330

+1
source

In my case, the problem occurs when moving Jenkins from one server to another. It seems that when copying the home folder this problem appears.

This explains how to fix these invalid directories. I will copy the steps here for future reference:

 # Logon on the master where you have the issue ssh jenkins-machine # Shutdown the jenkins master (take care that nothing is running) sudo service jenkins stop # Find all erroneous directories find /opt/jenkins/jobs -type d \( -name "last*Build" -o -name "lastStable" -o -name "lastSuccessful" \) # Review the list of erroneous directories # Rename them find /opt/jenkins/jobs -type d \( -name "last*Build" -o -name "lastStable" -o -name "lastSuccessful" \) -exec mv {} {}.err \; # Restart jenkins sudo service jenkins start 

And if it works, delete the moved directories:

 #In the future you can delete these directory if everything is fine with find /opt/jenkins/jobs -type d -name "*.err" -exec rm -rf {} \; 
+3
source

Source: https://habr.com/ru/post/1202125/


All Articles