Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.nio.file.DirectoryNotEmptyException when deleting lastSuccessful/lastStable jenkins

Tags:

java

jenkins

when running a jenkins job, 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?

like image 717
coderatchet Avatar asked Sep 09 '14 06:09

coderatchet


2 Answers

In my case, the issue appears when moving Jenkins from one server to other. Seems that when copying the home folder, this issue appears.

In this link explains how to fix these erroneous directories. I 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, remove 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 {} \;
like image 67
King Midas Avatar answered Nov 05 '22 16:11

King Midas


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

like image 20
stacky Avatar answered Nov 05 '22 15:11

stacky