Old build directories remain on filesystem after log rotation

Last Reviewed:2025-12-31()
1 minute readKnowledge base

Issue

Build directories continue to exist on the filesystem even though the builds do not appear in the UI.

Log rotation appears to have deleted the builds from the controller, but the corresponding directories in $JENKINS_HOME/jobs/$JOB_NAME/builds remain on disk.

This causes disk space exhaustion or inode exhaustion despite builds being removed from the UI.

Explanation

Build directories that are missing the build.xml file cannot be fully deleted by the log rotator.

When log rotation runs, the controller removes the build from its internal records and attempts to delete the directory from the filesystem.

If the build.xml file is missing or inaccessible during the deletion process, the filesystem cleanup fails while the logical deletion succeeds.

This leaves orphaned build directories on disk that are no longer visible in the UI.

Workaround

Manually identify and delete orphaned build directories that are missing the build.xml file.

  1. Navigate to $JENKINS_HOME/jobs/$JOB_NAME/builds

  2. Identify build directories that are missing build.xml:

    for dir in */; do if [ ! -f "${dir}build.xml" ]; then echo "Missing build.xml in: ${dir}" fi done
  3. After verifying the builds are safe to delete, remove the directories

  4. Reload configuration from disk using: Manage Jenkins  Reload Configuration from Disk

Investigate the root cause of why build.xml files are being removed to prevent this issue from recurring.

Tested product/plugin versions

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.