Skip to content

Commit 5d6d77b

Browse files
Rename "slave" to "agent" in the disableSlaveNodeStartsWith script (jenkinsci#115)
1 parent cb8bd17 commit 5d6d77b

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

scriptler/disableSlaveNodeStartsWith.groovy

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
/*** BEGIN META {
2-
"name" : "Disable Jenkins Hudson slaves nodes gracefully for all slaves starting with a given value",
3-
"comment" : "Disables Jenkins Hudson slave nodes gracefully - waits until running jobs are complete.",
2+
"name" : "Disable Jenkins agent nodes gracefully for all slaves starting with a given value",
3+
"comment" : "Disables Jenkins agent nodes gracefully - waits until running jobs are complete.",
44
"parameters" : [ 'slaveStartsWith'],
55
"core": "1.350",
66
"authors" : [
77
{ name : "GigaAKS" }, { name : "Arun Sangal" }
88
]
99
} END META**/
1010

11-
// This scriptler script will mark Jenkins slave nodes offline for all slaves which starts with a given value.
12-
// It will wait for any slave nodes which are running any job(s) and then delete them.
11+
// This scriptler script will mark Jenkins agent nodes offline for all slaves which starts with a given value.
12+
// It will wait for any agent nodes which are running any job(s) and then delete them.
1313
// It requires only one parameter named: slaveStartsWith and value can be passed as: "swarm-".
1414

1515
import java.util.*
1616
import jenkins.model.*
1717
import hudson.model.*
1818
import hudson.slaves.*
1919

20-
def atleastOneSlaveRunnning = true;
20+
def atleastOneAgentRunnning = true;
2121
def time = new Date().format("HH:mm MM/dd/yy z",TimeZone.getTimeZone("EST"))
2222

23-
while (atleastOneSlaveRunnning) {
23+
while (atleastOneAgentRunnning) {
2424

2525
//First thing - set the flag to false.
26-
atleastOneSlaveRunnning = false;
26+
atleastOneAgentRunnning = false;
2727
time = new Date().format("HH:mm MM/dd/yy z",TimeZone.getTimeZone("EST"))
2828

29-
for (aSlave in hudson.model.Hudson.instance.slaves) {
29+
for (agent in hudson.model.Hudson.instance.slaves) {
3030

3131
println "-- Time: " + time;
3232
println ""
33-
//Dont do anything if the slave name is "ansible01"
34-
if ( aSlave.name == "ansible01" ) {
33+
//Dont do anything if the agent name is "ansible01"
34+
if ( aAgent.name == "ansible01" ) {
3535
continue;
3636
}
37-
if ( aSlave.name.indexOf(slaveStartsWith) == 0) {
38-
println "Active slave: " + aSlave.name;
37+
if ( agent.name.indexOf(slaveStartsWith) == 0) {
38+
println "Active agent: " + agent.name;
3939

40-
println('\tcomputer.isOnline: ' + aSlave.getComputer().isOnline());
41-
println('\tcomputer.countBusy: ' + aSlave.getComputer().countBusy());
40+
println('\tcomputer.isOnline: ' + agent.getComputer().isOnline());
41+
println('\tcomputer.countBusy: ' + agent.getComputer().countBusy());
4242
println ""
43-
if ( aSlave.getComputer().isOnline()) {
44-
aSlave.getComputer().setTemporarilyOffline(true,null);
45-
println('\tcomputer.isOnline: ' + aSlave.getComputer().isOnline());
43+
if ( agent.getComputer().isOnline()) {
44+
agent.getComputer().setTemporarilyOffline(true,null);
45+
println('\tcomputer.isOnline: ' + agent.getComputer().isOnline());
4646
println ""
4747
}
48-
if ( aSlave.getComputer().countBusy() == 0 ) {
48+
if ( agent.getComputer().countBusy() == 0 ) {
4949
time = new Date().format("HH:mm MM/dd/yy z",TimeZone.getTimeZone("EST"))
50-
println("-- Shutting down node: " + aSlave.name + " at " + time);
51-
aSlave.getComputer().doDoDelete();
50+
println("-- Shutting down node: " + agent.name + " at " + time);
51+
agent.getComputer().doDoDelete();
5252
} else {
53-
atleastOneSlaveRunnning = true;
53+
atleastOneAgentRunnning = true;
5454
}
5555
}
5656
}
5757
//Sleep 60 seconds
58-
if(atleastOneSlaveRunnning) {
58+
if(atleastOneAgentRunnning) {
5959
println ""
6060
println "------------------ sleeping 60 seconds -----------------"
6161
sleep(60*1000);

0 commit comments

Comments
 (0)