How to find out the number of jobs from each job types

Article ID:360031145972
1 minute readKnowledge base

Issue

  • I want to know how many freestyle/maven/pipeline jobs there are in Jenkins.

Resolution

Using Groovy Script

You can run a script from the Groovy Script Console under Manage Jenkins -→ Script Console:

Set<String> jobTypes = new HashSet<String>();

Jenkins.instance.allItems(AbstractItem.class).each {
    jobTypes.add(it.class)
}

jobTypes.each { clazz ->
  println clazz.getCanonicalName() + ": " + Jenkins.instance.getAllItems(clazz).size()
}

println "--------------------------------------------------------------------------"
println "Total items : " + Jenkins.instance.getAllItems(AbstractItem.class).size()

return

Other useful groovy scripts can also be found in:

Using Support Bundle

You can also find the job statistics from the support bundle. Here is how:

2) Generate a support bundle.

3) Unzip the file

4) Aggregate job type statistics can be found under the root folder in items.md file.

Tested product/plugin versions

  • CloudBees Jenkins 2.176.2.3

  • CloudBees Support Plugin 3.22

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.