I'm trying to list out all the freestyle and pipeline jobs in Jenkins through groovy. I'm using the below script but it's not accurately listing all the pipeline jobs.
import hudson.triggers.*
import org.jenkinsci.plugins.workflow.job.*
def logSpec = { it, getTrigger -> String spec = getTrigger(it)?.getSpec(); if (spec) println (it.getFullName() )}
println("--- Jenkins Pipeline jobs List ---")
Jenkins.getInstance().getAllItems(WorkflowJob.class).each() { logSpec(it, {it.getSCMTrigger()}) }
println("\n--- Jenkins FreeStyle jobs List ---")
Jenkins.getInstance().getAllItems(FreeStyleProject.class).each() { logSpec(it, {it.getSCMTrigger()}) }
println '\nDone.'
I would like to also list the multibranch pipelines and declarative pipelines. Any help would be much appreciated!