Issue
- Is there a way I can list all Jenkins jobs on a server?
Environment
- CloudBees CI (CloudBees Core)
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed Master
- CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
- CloudBees CI (CloudBees Core) on traditional platforms - Client Master
- CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
- CloudBees Jenkins Enterprise
- CloudBees Jenkins Enterprise - Managed Master
- CloudBees Jenkins Enterprise - Operations Center
- CloudBees Jenkins Team
- CloudBees Jenkins Platform - Client Master
- CloudBees Jenkins Platform - Operations Center
- Jenkins LTS
Resolution
Go to Script Console under Manage Jenkins, this script will print the name of all jobs including jobs inside of a folder and the folders themselves:
Jenkins.instance.getAllItems(AbstractItem.class).each {
println it.fullName + " - " + it.class
};
This script will print the name of all jobs including jobs inside of a folder, but not the folders themselves.
Jenkins.instance.getAllItems(Job.class).each{
println it.name + " - " + it.class
}
This script will recursively print the name of all jobs implementing the AbstractProject class, i.e. Freestyle and Maven jobs.
Jenkins.instance.getAllItems(AbstractProject.class).each {it ->
println it.fullName;
}
This script will recursively print the name of all the Multibranch jobs.
Jenkins.instance.getAllItems(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject).each {it ->
println it.fullName;
}
Tested product/plugin versions
- CloudBees Jenkins Enterprise 2.235.2.3
- CloudBees CI 2.235.2.3
19 Comments