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

java.nio.file.DirectoryNotEmptyException: /home/dev/.jenkins/jobs/MyBuild/lastSuccessful

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • tomcat/centos

      Hello,

      On the latest version 1.546 for a maven build I get this error:

      Started by user anonymous
      ln builds/lastSuccessfulBuild /home/dev/.jenkins/jobs/MyBuild/lastSuccessful failed
      java.nio.file.DirectoryNotEmptyException: /home/dev/.jenkins/jobs/MyBuild/lastSuccessful
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:241)
      	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
      	at java.nio.file.Files.deleteIfExists(Files.java:1116)
      	at sun.reflect.GeneratedMethodAccessor313.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at hudson.Util.createSymlinkJava7(Util.java:1146)
      	at hudson.Util.createSymlink(Util.java:1064)
      	at hudson.model.Run.createSymlink(Run.java:1783)
      	at hudson.model.Run.updateSymlinks(Run.java:1764)
      	at hudson.model.Run.execute(Run.java:1676)
      	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:231)
      ln builds/lastStableBuild /home/dev/.jenkins/jobs/MyBuild/lastStable failed
      java.nio.file.DirectoryNotEmptyException: /home/dev/.jenkins/jobs/MyBuild/lastStable
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:241)
      	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
      	at java.nio.file.Files.deleteIfExists(Files.java:1116)
      	at sun.reflect.GeneratedMethodAccessor313.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at hudson.Util.createSymlinkJava7(Util.java:1146)
      	at hudson.Util.createSymlink(Util.java:1064)
      	at hudson.model.Run.createSymlink(Run.java:1783)
      	at hudson.model.Run.updateSymlinks(Run.java:1765)
      	at hudson.model.Run.execute(Run.java:1676)
      	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:231)
      Building in workspace /home/dev/.jenkins/jobs/MyBuild/workspace
      Updating svn://myweb.com/repos/Events/trunk at revision '2014-01-10T15:06:09.745 +0000'
      At revision 1974
      WARNING: clock of the subversion server appears to be out of sync. This can result in inconsistent check out behavior.
      no change for svn://myweb.com/repos/Events/trunk since the previous build
      Parsing POMs
      

      It does not seem to get the latest update from the svn.

      Switching back to 1.544 fixed the issue.

      Cheers Greg

          [JENKINS-21330] java.nio.file.DirectoryNotEmptyException: /home/dev/.jenkins/jobs/MyBuild/lastSuccessful

          Bob Balli added a comment - - edited

          I am having below problem with Jenkins 1.597. Even though build is done successfully but I can see below error on start of log. I have been using this version from couple months now. I am not sure what causes this problem.

          ln builds\lastSuccessfulBuild F:\Jenkins\jobs\STDVERSION\lastSuccessful failed
          java.nio.file.DirectoryNotEmptyException: F:\Jenkins\jobs\STDVERSION\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.GeneratedMethodAccessor3435.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at hudson.Util.createSymlinkJava7(Util.java:1200)
          at hudson.Util.createSymlink(Util.java:1118)
          at hudson.model.Run.createSymlink(Run.java:1822)
          at hudson.model.Run.updateSymlinks(Run.java:1803)
          at hudson.model.Run.execute(Run.java:1716)
          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 F:\Jenkins\jobs\STD754_Consolidation01_Clean\lastStable failed
          java.nio.file.DirectoryNotEmptyException: F:\Jenkins\jobs\STD754_Consolidation01_Clean\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.GeneratedMethodAccessor3435.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at hudson.Util.createSymlinkJava7(Util.java:1200)
          at hudson.Util.createSymlink(Util.java:1118)
          at hudson.model.Run.createSymlink(Run.java:1822)
          at hudson.model.Run.updateSymlinks(Run.java:1804)
          at hudson.model.Run.execute(Run.java:1716)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:89)
          at hudson.model.Executor.run(Executor.java:240)

          Bob Balli added a comment - - edited I am having below problem with Jenkins 1.597. Even though build is done successfully but I can see below error on start of log. I have been using this version from couple months now. I am not sure what causes this problem. ln builds\lastSuccessfulBuild F:\Jenkins\jobs\STDVERSION\lastSuccessful failed java.nio.file.DirectoryNotEmptyException: F:\Jenkins\jobs\STDVERSION\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.GeneratedMethodAccessor3435.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at hudson.Util.createSymlinkJava7(Util.java:1200) at hudson.Util.createSymlink(Util.java:1118) at hudson.model.Run.createSymlink(Run.java:1822) at hudson.model.Run.updateSymlinks(Run.java:1803) at hudson.model.Run.execute(Run.java:1716) 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 F:\Jenkins\jobs\STD754_Consolidation01_Clean\lastStable failed java.nio.file.DirectoryNotEmptyException: F:\Jenkins\jobs\STD754_Consolidation01_Clean\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.GeneratedMethodAccessor3435.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at hudson.Util.createSymlinkJava7(Util.java:1200) at hudson.Util.createSymlink(Util.java:1118) at hudson.model.Run.createSymlink(Run.java:1822) at hudson.model.Run.updateSymlinks(Run.java:1804) at hudson.model.Run.execute(Run.java:1716) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240)

          Iain Smith added a comment -

          Im getting this issue on Jenkins ver. 1.617

          java.nio.file.DirectoryNotEmptyException: /Users/jenkins/.jenkins/jobs/Nightly/jobs/Internal_Nightly/lastSuccessful
          	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
          	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
          	at java.nio.file.Files.deleteIfExists(Files.java:1165)
          	at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:497)
          	at hudson.Util.createSymlinkJava7(Util.java:1225)
          	at hudson.Util.createSymlink(Util.java:1143)
          	at hudson.model.Run.createSymlink(Run.java:1848)
          	at hudson.model.Run.updateSymlinks(Run.java:1829)
          	at hudson.model.Run.execute(Run.java:1742)
          	at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73)
          	at hudson.model.ResourceController.execute(ResourceController.java:98)
          	at hudson.model.Executor.run(Executor.java:374)
          
          java.nio.file.DirectoryNotEmptyException: /Users/jenkins/.jenkins/jobs/Nightly/jobs/Internal_Nightly/lastStable
          	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
          	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
          	at java.nio.file.Files.deleteIfExists(Files.java:1165)
          	at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:497)
          	at hudson.Util.createSymlinkJava7(Util.java:1225)
          	at hudson.Util.createSymlink(Util.java:1143)
          	at hudson.model.Run.createSymlink(Run.java:1848)
          	at hudson.model.Run.updateSymlinks(Run.java:1830)
          	at hudson.model.Run.execute(Run.java:1742)
          	at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73)
          	at hudson.model.ResourceController.execute(ResourceController.java:98)
          	at hudson.model.Executor.run(Executor.java:374)
          

          Iain Smith added a comment - Im getting this issue on Jenkins ver. 1.617 java.nio.file.DirectoryNotEmptyException: /Users/jenkins/.jenkins/jobs/Nightly/jobs/Internal_Nightly/lastSuccessful at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242) at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108) at java.nio.file.Files.deleteIfExists(Files.java:1165) at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at hudson.Util.createSymlinkJava7(Util.java:1225) at hudson.Util.createSymlink(Util.java:1143) at hudson.model.Run.createSymlink(Run.java:1848) at hudson.model.Run.updateSymlinks(Run.java:1829) at hudson.model.Run.execute(Run.java:1742) at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:374) java.nio.file.DirectoryNotEmptyException: /Users/jenkins/.jenkins/jobs/Nightly/jobs/Internal_Nightly/lastStable at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242) at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108) at java.nio.file.Files.deleteIfExists(Files.java:1165) at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at hudson.Util.createSymlinkJava7(Util.java:1225) at hudson.Util.createSymlink(Util.java:1143) at hudson.model.Run.createSymlink(Run.java:1848) at hudson.model.Run.updateSymlinks(Run.java:1830) at hudson.model.Run.execute(Run.java:1742) at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:374)

          Werner Mairl added a comment - - edited

          Same Issue at 1.609.3 (on windows)
          To reproduce: deleted ALL old builds (so there is no lastsuccessfull/laststable available) with:

          import hudson.model.*
          import java.util.Date
          hudson = Hudson.instance
          for (job in hudson.projects) {
          job.getBuilds().each

          { it.delete() }

          }

          It seems that the exception is caused by the code that creates the console output for upstream/downstream projects
          i'm using "Build other Projects (extended)" post build actions

          Started by upstream project "Trunk.XXX.UpdateVersion" build number 521
          originally caused by:
          Started by upstream project "Trunk.XXX.BuildStarter" build number 252
          originally caused by:
          Started by user Administrator
          ln builds\lastSuccessfulBuild C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\lastSuccessful failed
          java.nio.file.DirectoryNotEmptyException: C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\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.GeneratedMethodAccessor403.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at hudson.Util.createSymlinkJava7(Util.java:1224)
          at hudson.Util.createSymlink(Util.java:1142)
          at hudson.model.Run.createSymlink(Run.java:1842)
          at hudson.model.Run.updateSymlinks(Run.java:1823)
          at hudson.model.Run.execute(Run.java:1736)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:381)
          ln builds\lastStableBuild C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\lastStable failed
          java.nio.file.DirectoryNotEmptyException: C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\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.GeneratedMethodAccessor403.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at hudson.Util.createSymlinkJava7(Util.java:1224)
          at hudson.Util.createSymlink(Util.java:1142)
          at hudson.model.Run.createSymlink(Run.java:1842)
          at hudson.model.Run.updateSymlinks(Run.java:1824)
          at hudson.model.Run.execute(Run.java:1736)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:381)

          Anything else that i can do to help to isolate/solve the bug?

          This issue is assigned to the Component "Maven Plugin"
          not sure what this means but basically i'm not using that plugin (installed but disabled)

          Werner Mairl added a comment - - edited Same Issue at 1.609.3 (on windows) To reproduce: deleted ALL old builds (so there is no lastsuccessfull/laststable available) with: import hudson.model.* import java.util.Date hudson = Hudson.instance for (job in hudson.projects) { job.getBuilds().each { it.delete() } } It seems that the exception is caused by the code that creates the console output for upstream/downstream projects i'm using "Build other Projects (extended)" post build actions Started by upstream project "Trunk.XXX.UpdateVersion" build number 521 originally caused by: Started by upstream project "Trunk.XXX.BuildStarter" build number 252 originally caused by: Started by user Administrator ln builds\lastSuccessfulBuild C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\lastSuccessful failed java.nio.file.DirectoryNotEmptyException: C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\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.GeneratedMethodAccessor403.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at hudson.Util.createSymlinkJava7(Util.java:1224) at hudson.Util.createSymlink(Util.java:1142) at hudson.model.Run.createSymlink(Run.java:1842) at hudson.model.Run.updateSymlinks(Run.java:1823) at hudson.model.Run.execute(Run.java:1736) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:381) ln builds\lastStableBuild C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\lastStable failed java.nio.file.DirectoryNotEmptyException: C:\JENKINS\HOME_MASTER\jobs\Trunk.XXX.Build\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.GeneratedMethodAccessor403.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at hudson.Util.createSymlinkJava7(Util.java:1224) at hudson.Util.createSymlink(Util.java:1142) at hudson.model.Run.createSymlink(Run.java:1842) at hudson.model.Run.updateSymlinks(Run.java:1824) at hudson.model.Run.execute(Run.java:1736) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:381) Anything else that i can do to help to isolate/solve the bug? This issue is assigned to the Component "Maven Plugin" not sure what this means but basically i'm not using that plugin (installed but disabled)

          We experience this issue here randomly, too, and it's still present in version 1.622.
          Is there any work-around one could use until it's fixed?

          Christian Keck added a comment - We experience this issue here randomly, too, and it's still present in version 1.622. Is there any work-around one could use until it's fixed?

          Julio Nobre added a comment -

          Just to give my two cents on this issue, which started to happen just after a renaming Tristan project to Tristan (local)

          To solve it, I renamed my C:\Program Files (x86)\Jenkins\jobs\Tristan (local)*lastSuccessful* folder to lastSuccessful.old

          This suggest that may be Jenkins should choose among one of the following approaches:

          • Jenkins refactors project's configuration files so they reflect the new project name;
          • Or Jenkins, forces user to aknowledge (checkbox) that he will loose Last Successful Build *information because because folder *lastSuccessful *will be renamed to *lastSuccessful.nnn, where nnn is sequencial number to prevent folder overwriting.

          Hope this helps

          I am using Jenkins v1.643

          Julio Nobre added a comment - Just to give my two cents on this issue, which started to happen just after a renaming Tristan project to Tristan (local) To solve it, I renamed my C:\Program Files (x86)\Jenkins\jobs\Tristan (local)*lastSuccessful* folder to lastSuccessful.old This suggest that may be Jenkins should choose among one of the following approaches: Jenkins refactors project's configuration files so they reflect the new project name; Or Jenkins, forces user to aknowledge (checkbox) that he will loose Last Successful Build *information because because folder *lastSuccessful *will be renamed to *lastSuccessful.nnn , where nnn is sequencial number to prevent folder overwriting. Hope this helps I am using Jenkins v1.643

          Hari Dara added a comment -

          This started happening on a new Jenkins server that a teammate was trying to setup by cloning an existing one, and I found out that he used scp -r to copy the whole working tree and that resulted in the lastSuccessful and lastStable soft-links to get converted to physical directories. I guess Jenkins was trying to remove it like it is a file (which a soft-link is), but since it turned out to be a directory that is not empty, it is causing this exception. When you remove/rename these directories, it clears the path for Jenkins to recreate the soft-links thus solving the problem.

          Perhaps Jenkins can handle this case more gracefully?

          Hari Dara added a comment - This started happening on a new Jenkins server that a teammate was trying to setup by cloning an existing one, and I found out that he used scp -r to copy the whole working tree and that resulted in the lastSuccessful and lastStable soft-links to get converted to physical directories. I guess Jenkins was trying to remove it like it is a file (which a soft-link is), but since it turned out to be a directory that is not empty, it is causing this exception. When you remove/rename these directories, it clears the path for Jenkins to recreate the soft-links thus solving the problem. Perhaps Jenkins can handle this case more gracefully?

          Jesse Glick added a comment -

          `createSymlinkJava7` could detect this case and either report the real mistake, or simply delete the bogus directory.

          Jesse Glick added a comment - `createSymlinkJava7` could detect this case and either report the real mistake, or simply delete the bogus directory.

          Hari Dara added a comment -

          Looks like this issue got fixed in the change d97b083. @kohsuke

          Hari Dara added a comment - Looks like this issue got fixed in the change d97b083 . @kohsuke

          Sophia Guo added a comment -

          happens in Jenkins is at 2.46.3

          Sophia Guo added a comment - happens in Jenkins is at 2.46.3

          xu chan added a comment - - edited

          Thanks ! error gone . @haridsv 

          xu chan added a comment - - edited Thanks ! error gone . @ haridsv  

            Unassigned Unassigned
            gregh3269 Greg Huber
            Votes:
            21 Vote for this issue
            Watchers:
            30 Start watching this issue

              Created:
              Updated: