-
Notifications
You must be signed in to change notification settings - Fork 557
/
checkNodesLauncherVersion.groovy
44 lines (41 loc) · 1.4 KB
/
checkNodesLauncherVersion.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*** BEGIN META {
"name" : "Check Nodes Version",
"comment" : "Check the .jar version and the java version of the Nodes against the Master versions",
"parameters" : [ ],
"core": "1.609",
"authors" : [
{ name : "Allan Burdajewicz" }
]
} END META**/
import hudson.remoting.Launcher
import hudson.slaves.SlaveComputer
import jenkins.model.Jenkins
def expectedAgentVersion = Launcher.VERSION
def expectedJavaVersion = System.getProperty("java.version")
println "Master"
println " Expected Agent Version = '${expectedAgentVersion}'"
println " Expected Java Version = '${expectedJavaVersion}'"
Jenkins.instance.getComputers()
.findAll { it instanceof SlaveComputer }
.each { computer ->
println "Node '${computer.name}'"
if (!computer.getChannel()) {
println " is disconnected."
} else {
def isOk = true
def agentVersion = computer.getSlaveVersion()
if (!expectedAgentVersion.equals(agentVersion)) {
println " expected agent version '${expectedAgentVersion}' but got '${agentVersion}'"
isOk = false
}
def javaVersion = computer.getSystemProperties().get("java.version")
if (!expectedJavaVersion.equals(javaVersion)) {
println " expected java version '${expectedJavaVersion}' but got '${javaVersion}'"
isOk = false
}
if(isOk) {
println " OK"
}
}
}
return;