Awesome! This is exactly what I was looking for! Much appreciated Victor! Best regards Ioannis
On Wednesday, December 2, 2015 at 7:55:39 AM UTC-5, Victor Martinez wrote: > > You can easily filter by type: > http://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html#getAllItems(java.lang.Class) > > Folder class: > https://github.com/jenkinsci/cloudbees-folder-plugin/blob/master/src/main/java/com/cloudbees/hudson/plugins/folder/Folder.java#L72 > > Then you can use getAllJobs(): > http://javadoc.jenkins-ci.org/hudson/model/Item.html#getAllJobs() > > See the below script: > > jenkins.model.Jenkins.instance?.getAllItems(com.cloudbees.hudson.plugins.folder.Folder).each > > { folder -> > println "Folder - ${folder}" > folder.getItems().each { > println "\t job - ${it}" > } > } > > It's worth if you don't use deprecated methods/classes > > Cheers > > On Wednesday, 2 December 2015 13:29:37 UTC+1, Ioannis Moutsatsos wrote: >> >> I need some help accessing programmatically the job names inside a >> CloudBees folder (using CloudBees Folders Plugin >> <https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Folders+Plugin>). >> I used to use code like this to get all the job names >> >> // Access to the Hudson Singleton >> hudsonInstance = hudson.model.Hudson.instance >> >> >> // Retrieve all Jobs >> allItems = hudsonInstance.items >> choices=[] >> >> >> // Create choices list >> allItems.each { job -> >> choices.add(job.name) >> } >> return choices >> >> >> However, now all I get is the list of Cloudbees folders. I would like to >> get the job names inside these folders. >> Thanks for any feedback. >> Ioannis >> > -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/6be79796-b66b-41f5-b748-cdb63984443e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
