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

Issue

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

Environment

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:

1) Install the Support Core Plugin (see What is a support-bundle and how to create one).

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

Have more questions?

0 Comments

Please sign in to leave a comment.