Child pages
  • Display jobs group by the build steps they use

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Bored to search randomly jobs configuration to found a particular build step example.
This script may help you.

import hudson.model.*
import hudson.tasks.*

//All the projects on which we can apply the getBuilders method
def allProjects = Hudson.instance.items.findAll{ it instanceof Project }

//All the registered build steps in the current Jenkins Instance
def allBuilders = Builder.all()

//Group the projects by the build steps used
def projectsGroupByBuildSteps = allBuilders.inject([:]){
   map, builder ->   
   map[builder.clazz.name] = allProjects.findAll{it.builders.any{ it.class.name.contains(builder.clazz.name)}}.collect{it.name}
   map
}

//presentation
projectsGroupByBuildSteps.each{
   println """--- $it.key ---
   \t$it.value\n"""
}
  • No labels

2 Comments

  1. Unknown User (hujirong)

    Runs on Jenkins 2.7.1, it produces an empty result for all builders, like below:Result: {org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder=[], com.hp.application.automation.tools.settings.AlmServerSettingsBuilder=[], com.hp.application.automation.tools.settings.MCServerSettingsBuilder=[],

  2. Unknown User (ianw)

    I had to use: def allProjects = Hudson.instance.allItems.findAll{ it instanceof Project }

    We use folders to organize our jobs and the original ( Hudson.instance.items.findAll ) only listed the jobs at the top level.

    You probably also want to map collect{it.fullName} to show the folders

    The original page is 7+ years old, so things have evolved. Using Jenkins 2.121.3

    ps: switching to Publisher.all() will report all the post-build steps, which is equally handy.