Skip to content

Instantly share code, notes, and snippets.

@ykhandelwal913
Created June 21, 2019 04:56
Show Gist options
  • Save ykhandelwal913/3eb60d092689afaf1ac90f8a22751a22 to your computer and use it in GitHub Desktop.
Save ykhandelwal913/3eb60d092689afaf1ac90f8a22751a22 to your computer and use it in GitHub Desktop.
import hudson.model.labels.*
Jenkins.instance.getAllItems(Job.class).each{
//println it.name + " - " + it.class + " - " + it.getAssignedLabelString()
if(it.class.simpleName == 'FreeStyleProject') {
jobLabelString = it.getAssignedLabelString()
println it.name + " - " + jobLabelString
//if(jobLabelString.contains('Slave-')){
//if(jobLabelString == "Build_Farm"){
// it.assignedLabel = new LabelAtom('TESTFARM')
// it.save()
//}
}
else if(it.class.simpleName == 'WorkflowJob') {
jobLabelString = it.getDefinition().getScript()
println it.name + " - " + jobLabelString
} else if (it.class == 'com.tikal.jenkins.plugins.multijob.MultiJobProject'){
println "nothing"
}
else {
//throw new Exception("Don't know how to handle class: ${it.getClass()}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment