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

After unshelving a build, symlinks are broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Critical Critical
    • shelve-project-plugin
    • None
    • Any shelve plugin version
      Jenkins version >= 2.91

      After unshelving a project, the builds start with a stack for each symlink that are created by Jenkins eg:

       

      ln builds/lastSuccessfulBuild jenkins-home/jobs/freestyle/lastSuccessful failed
      java.nio.file.DirectoryNotEmptyException: jenkins-home/jobs/freestyle/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 hudson.Util.createSymlink(Util.java:1351)
      	at hudson.model.Run.createSymlink(Run.java:1937)
      	at hudson.model.Run.updateSymlinks(Run.java:1918)
      	at hudson.model.Run.execute(Run.java:1796)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)

      Or

      ln builds/lastStableBuild jenkins-home/jobs/freestyle/lastStable failed java.nio.file.DirectoryNotEmptyException: jenkins-home/jobs/freestyle/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 hudson.Util.createSymlink(Util.java:1351) at hudson.model.Run.createSymlink(Run.java:1937) at hudson.model.Run.updateSymlinks(Run.java:1919) at hudson.model.Run.execute(Run.java:1796) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)

      Explanation

      Issue is due to a behavior change in Jenkins Core 2.91 that outlines an old bug in core. See JENKINS-52781 for details.

       

      Workaround

      Waiting for a fix for JENKINS-52781, one can clean up the executors with this script:

      • dry run (make sure of what you delete):
      find ${JENKINS_HOME}/jobs/ -type d \( -name lastFailedBuild -o -name lastSuccessfulBuild -o -name lastUnsuccessfulBuild -o -name lastStableBuild -o -name lastUnstableBuild -o -name lastFailed -o -name lastSuccessful -o -name lastUnsuccessful -o -name lastStable -o -name lastUnstable \)
      
      • delete the symlinks:
      find ${JENKINS_HOME}/jobs/ -type d \( -name lastFailedBuild -o -name lastSuccessfulBuild -o -name lastUnsuccessfulBuild -o -name lastStableBuild -o -name lastUnstableBuild -o -name lastFailed -o -name lastSuccessful -o -name lastUnsuccessful -o -name lastStable -o -name lastUnstable \) -exec rm -rfv "{}" \;
      

            pierrebtz Pierre Beitz
            pierrebtz Pierre Beitz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: