Skip to content

Instantly share code, notes, and snippets.

@rodrigozrusso
Created March 8, 2016 16:58
Show Gist options
  • Save rodrigozrusso/3d3d0dd997d5cd8c54ff to your computer and use it in GitHub Desktop.
Save rodrigozrusso/3d3d0dd997d5cd8c54ff to your computer and use it in GitHub Desktop.
Assign label to all jobs in jenkins
import hudson.model.*
import hudson.model.labels.*
import hudson.maven.*
import hudson.tasks.*
import hudson.plugins.git.*
hudsonInstance = hudson.model.Hudson.instance
allItems = hudsonInstance.allItems
buildableItems = allItems.findAll{ job -> job instanceof BuildableItemWithBuildWrappers }
buildableItems.each { item ->
boolean shouldSave = false
item.allJobs.each { job ->
job.assignedLabel = new LabelAtom('<label-name>')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment