Answers: <p>They quick and dirty answer is to &quot;<a href="https://wiki.jenkins.io/display/JENKINS/Display+jobs+group+by+the+build+steps+they+use" rel="nofollow noreferrer">Display jobs group by the build steps they use</a>&quot; as updated below.</p>
  <pre><code>import hudson.model.*
  import hudson.tasks.*
  
  //All the projects on which we can apply the getBuilders method
  def allProjects = Jenkins.instance.allItems.findAll{ it instanceof Project }
  
  //All the registered build steps in the current Jenkins Instance
  def allSteps = Builder.all()
  
  //Group the projects by the build steps used
  def projectsGroupBySteps = allSteps.inject([:]){
     map, step -&gt;
     map[step.clazz.name] = allProjects.findAll{it.builders.any{ 
          it.class.name.contains(step.clazz.name)}}.collect{it.fullName}
     map
  }
  
  //Presentation
  projectsGroupBySteps.sort().each{
      println &quot;--- ($it.value.size) $it.key ---&quot;
  }
  println ''
  
  println 'Occcurences:'
  projectsGroupBySteps.sort().each{
  println &quot;--- ($it.value.size) $it.key ---&quot;
      it.value.each {
          println it }
      println ''
  }
  return
  </code></pre>
  <p>Note that a job has multiple sections: <strong>builders</strong>, <strong>publishers</strong> and <strong>buildWrappers</strong>.
  Depending on what you are looking for, replace</p>
  <pre><code>[allSteps = Builder.all(), allProjects.findAll{it.builders.any ]
  [allSteps = Publisher.all(), allProjects.findAll{it.publishers.any ]
  [allSteps = BuildWrapper.all(), allProjects.findAll{it.buildWrappers.any ]
  </code></pre>
  <p>Plugins may also be involved in the <strong>SCM</strong> section and as <strong>properties</strong> (eg: <code>hudson.plugins.buildblocker.BuildBlockerProperty</code>, <code>com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty</code>)</p>
  <p>Obviously, same limitations of plugin-usage apply: does not scan pipeline steps plugin usage or build steps nested within an <code>org.jenkinsci.plugins.conditionalbuildstep</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2021-01-27T09:16:59.897Z
Answers: 2021-01-27T10:18:01.190Z
Answers: 2021-01-27T10:18:01.190Z
Answers: Ian W
Body: <p>I'm trying to list the jenkins jobs per plugin is being utilized. I see there's a plugin in jenkins, <a href="https://github.com/jenkinsci/plugin-usage-plugin" rel="nofollow noreferrer">https://github.com/jenkinsci/plugin-usage-plugin</a>, which displays the plugins usage in the Jenkins UI. But how do i get the same output from the groovy script?</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-01-26T21:31:04.750Z
Comments: i've a jenkins master and i'm trying list the jobs or builds that are being utilized by a particular plugin. Ex: how many jobs are configured/used by maven plugin
Comments: Sachin
Comments: CC BY-SA 4.0
Comments: 2021-01-26T21:31:17.230Z
Comments: i was trying to test these scripts, support.cloudbees.com/hc/en-us/articles/216351528. In a similar way i want to list all the jobs configured with a particular plugin.
Comments: Sachin
Tags: <jenkins><jenkins-plugins><groovy>
Title: How do i print the list of jobs per plugin in Jenkins
UserDisplayName: Sachin
ThreadText: # How do i print the list of jobs per plugin in Jenkins
  
  (Asked by: username_0 on 2021-01-26)
  
  I'm trying to list the jenkins jobs per plugin is being utilized. I see there's a plugin in jenkins, <https://github.com/jenkinsci/plugin-usage-plugin>, which displays the plugins usage in the Jenkins UI. But how do i get the same output from the groovy script?
  
  **Tags:** jenkins, jenkins-plugins, groovy
  
  > **Comments:**
  > **username_0**: i've a jenkins master and i'm trying list the jobs or builds that are being utilized by a particular plugin. Ex: how many jobs are configured/used by maven plugin  
  > **username_0**: i was trying to test these scripts, support.cloudbees.com/hc/en-us/articles/216351528. In a similar way i want to list all the jobs configured with a particular plugin.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-27. Score: 1
  
  They quick and dirty answer is to "[Display jobs group by the build steps they use](https://wiki.jenkins.io/display/JENKINS/Display+jobs+group+by+the+build+steps+they+use)" as updated below.
  
  ```
  import hudson.model.*
  import hudson.tasks.*
  
  //All the projects on which we can apply the getBuilders method
  def allProjects = Jenkins.instance.allItems.findAll{ it instanceof Project }
  
  //All the registered build steps in the current Jenkins Instance
  def allSteps = Builder.all()
  
  //Group the projects by the build steps used
  def projectsGroupBySteps = allSteps.inject([:]){
     map, step ->
     map[step.clazz.name] = allProjects.findAll{it.builders.any{ 
          it.class.name.contains(step.clazz.name)}}.collect{it.fullName}
     map
  }
  
  //Presentation
  projectsGroupBySteps.sort().each{
      println "--- ($it.value.size) $it.key ---"
  }
  println ''
  
  println 'Occcurences:'
  projectsGroupBySteps.sort().each{
  println "--- ($it.value.size) $it.key ---"
      it.value.each {
          println it }
      println ''
  }
  return
  
  ```
  
  Note that a job has multiple sections: **builders**, **publishers** and **buildWrappers**.
  Depending on what you are looking for, replace
  
  ```
  [allSteps = Builder.all(), allProjects.findAll{it.builders.any ]
  [allSteps = Publisher.all(), allProjects.findAll{it.publishers.any ]
  [allSteps = BuildWrapper.all(), allProjects.findAll{it.buildWrappers.any ]
  
  ```
  
  Plugins may also be involved in the **SCM** section and as **properties** (eg: `hudson.plugins.buildblocker.BuildBlockerProperty`, `com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty`)
  
  Obviously, same limitations of plugin-usage apply: does not scan pipeline steps plugin usage or build steps nested within an `org.jenkinsci.plugins.conditionalbuildstep`
  
  
  ---
  
  