This file contains 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
hudson = hudson.model.Hudson.instance | |
hudson.slaves.each { | |
if(it.remoteFS.contains("C:")){ | |
it.labelString = it.labelString+ " "+"windows" | |
}else{ | |
it.labelString = it.labelString+ " "+"non_windows" | |
} | |
} | |
hudson.save() |
This file contains 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
for (aSlave in hudson.model.Hudson.instance.slaves) { | |
computer = aSlave.getComputer(); | |
// println computer | |
computer.setTemporarilyOffline(true) // To Disable all Nodes | |
// computer.setTemporarilyOffline(false) -- To Enable all nodes. | |
} |
This file contains 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 hudson.model.* | |
import hudson.AbortException; | |
def resolver = build.buildVariableResolver | |
// def node_names = resolver.resolve("NODE_LIST").split(",") | |
timeout_seconds = 600 // 10 mins | |
sleepTime=30 // seconds | |
def node_name=resolver.resolve("NODE_NAME").replaceAll("\\s","") | |
slave = Hudson.instance.slaves.find({it.name == node_name}); |
This file contains 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.Jenkins | |
import hudson.model.* | |
//get jenkins env var | |
thr = Thread.currentThread() | |
build = thr.executable | |
myVar = build.getEnvironment(listener).get('Months') | |
months= Integer.parseInt(myVar ) |
This file contains 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 hudson.model.* | |
import hudson.slaves.* | |
import hudson.util.* | |
import jenkins.model.* | |
def resolver = build.buildVariableResolver | |
def old_string = resolver.resolve("OLD_STRING") | |
def new_string = resolver.resolve("NEW_STRING") |
This file contains 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 hudson.model.* | |
int jobs=0; | |
long time=0; | |
hudson.model.Hudson.getInstance().getAllItems(Job.class).each { | |
build = it.getLastBuild() | |
if(build){ | |
action = build.getAction(jenkins.metrics.impl.TimeInQueueAction.class) | |
if(action){ | |
jobs++ |
This file contains 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 static groovy.json.JsonOutput.* | |
def labels=[] | |
def lbl_node=[:] | |
for (aSlave in hudson.model.Hudson.instance.slaves) { | |
tmp_lbl = aSlave.getLabelString().toString() | |
// println lbl | |
lbls=tmp_lbl.split(" ") | |
for (lbl in lbls){ |