File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Schedule with:
2
+ # schtasks.exe /create /tn Jenkins-Slave-Update /tr "powershell -NonInteractive -File c:\Tools\UpdateJenkinsSlave.ps1" /sc DAILY /ru Administrator /rp /st 01:00:00
3
+
4
+ $ErrorActionPreference = " Stop"
5
+
6
+ $jenkinsBaseUrl = " http://10.73.76.93:8080"
7
+ $jenkinsSlaveDir = " c:\Jenkins"
8
+
9
+ $tmpFile = " $jenkinsSlaveDir \slave.jar.tmp"
10
+ $slaveJar = " $jenkinsSlaveDir \slave.jar"
11
+
12
+ Invoke-WebRequest - Uri " $jenkinsBaseUrl /jnlpJars/slave.jar" - OutFile $tmpFile
13
+
14
+ $tmpFileHash = (Get-FileHash $tmpFile ).Hash
15
+ $oldFileHash = (Get-FileHash $slaveJar ).Hash
16
+
17
+ if ($tmpFileHash -ne $oldFileHash ) {
18
+ echo " Updating $slaveJar "
19
+ net stop ' Jenkins Slave'
20
+ get-process | where {$_.Name -eq ' java' } | kill
21
+ del $slaveJar
22
+ move $tmpFile $slaveJar
23
+ net start ' Jenkins Slave'
24
+ }
25
+ else {
26
+ echo " No need to update"
27
+ del $tmpFile
28
+ }
29
+
You can’t perform that action at this time.
0 commit comments