Last active
April 6, 2017 13:32
-
-
Save mgasiorowski/d7e9fcad4339abef1922412dfdc13f0e to your computer and use it in GitHub Desktop.
[Jenkins] Find jobs with specific node and change him
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.* | |
jenkinsInstance = jenkins.model.Jenkins.instance | |
allItems = jenkinsInstance.getAllItems() | |
for(int i = 0; i < allItems.size(); i++) { | |
if(!(allItems[i] instanceof com.cloudbees.hudson.plugins.folder.Folder) && !(allItems[i] instanceof org.jenkinsci.plugins.workflow.job.WorkflowJob) && allItems[i].getAssignedLabelString() =~ "centos"){ | |
allItems[i].setAssignedLabel(jenkins.model.Jenkins.instance.getLabel("centos_7.2")) | |
println(allItems[i].name + ": " + allItems[i].getAssignedLabel()) | |
} | |
} | |
return [:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment