Issue
You want to locate Folders/Multibranch jobs that are empty and no longer contains any item inside.
Environment
-
CloudBees Core on modern cloud platforms - Managed controller
-
CloudBees Core on modern cloud platforms - Operations Center
-
CloudBees Jenkins Enterprise
-
CloudBees Jenkins Enterprise - Managed controller
-
CloudBees Jenkins Enterprise - Operations center
Resolution
Go to Manage Jenkins > Script Console
and copy/paste the following script. It will print the name of all folders and Multibranch jobs with no items inside.
import com.cloudbees.hudson.plugins.folder.Folder import com.cloudbees.hudson.plugins.folder.AbstractFolder Jenkins.instance.getAllItems(AbstractFolder.class).each { folder -> if (isEmpty(folder)) { println folder.fullName + " - " + folder.class } }; return def isEmpty(folder) { return folder?.items?.size() == 0 }
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.