Global Build Discarders causes exceptions after Upgrading to 2.222.x

Article ID:360047094151
2 minute readKnowledge base


  • After upgrading CloudBees Core to 2.222.x, the Jenkins logs shows a lot of exception like the following:

      Also: java.nio.file.NoSuchFileException: <buildPath> -> <buildPath>
        at sun.nio.fs.UnixException.translateToIOException(
        at sun.nio.fs.UnixException.rethrowAsIOException(
        at sun.nio.fs.UnixCopyFile.move(
        at sun.nio.fs.UnixFileSystemProvider.move(
        at java.nio.file.Files.move(
        at hudson.model.Run.delete(
        at hudson.tasks.LogRotator.perform( Failed to rotate logs for [<buildDisplayName>]
        at hudson.tasks.LogRotator.perform(
        at hudson.model.Job.logRotate(
        at jenkins.model.JobGlobalBuildDiscarderStrategy.apply(
        at jenkins.model.BackgroundGlobalBuildDiscarder.lambda$processJob$0(
        at java.lang.Iterable.forEach(
        at jenkins.model.BackgroundGlobalBuildDiscarder.processJob(
        at jenkins.model.GlobalBuildDiscarderListener.onFinalized(
        at hudson.model.listeners.RunListener.fireFinalized(
        at hudson.model.Run.onEndBuilding(


Jenkins Core 2.222 introduce Global Build Discarders as mentioned in the release notes. Those strategies apply the discard build policy of jobs periodically every hour but also whenever a build completes - like the job build discarders do.

Whenever a build finish, the build discarder may be triggered twice for the same job and is subjected to a race condition in the build deletion logic. The race condition is captured by JENKINS-61687. Jenkins might try to delete the same build twice causing the exception shown above.

In most cases, the impact is minor. However if this happens very frequently - like in large and active environments - it can spam the Jenkins logs and may well cause performance issues on the controller.


Upgrade CloudBees CI to or later.


The workaround is to delete the Global Build Discarder Policies.

This can be done from the UI:

  • Go to Manage Jenkins  Configure System

  • Navigate to "Global Build Discarders"

  • Delete any of the "Project Build Discarder" or "Specific Build Discarder" that currently exist

  • Save

This can also be done via a Groovy script like the following:


Tested product/plugin versions

The latest update of this article has been tested and verified with: