adding proper cleanup scripts for windows CI

pull/5202/head
Sharif Elgamal 2019-08-26 17:41:10 -07:00
parent d585196646
commit 830be73615
No known key found for this signature in database
GPG Key ID: 23CC0225BD9FD702
3 changed files with 57 additions and 33 deletions

View File

@ -1,33 +0,0 @@
:: Copyright 2019 The Kubernetes Authors All rights reserved.
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
:: Periodically cleanup and reboot if no Jenkins subprocesses are running.
@echo off
call :jenkins
echo waiting to see if any jobs are coming in...
timeout 30
call :jenkins
echo doing it
taskkill /IM putty.exe
taskkill /F /IM java.exe
powershell -Command "Stop-VM minikube"
powershell -Command "Delete-VM minikube"
rmdir /S /Q C:\Users\admin\.minikube
shutdown /r
:jenkins
tasklist | find /i /n "e2e-windows-amd64.exe">NUL
if %ERRORLEVEL% == 0 exit 1
exit /B 0

View File

@ -0,0 +1,27 @@
function Jenkins {
Get-Process e2e-windows-amd64 2>$NULL
if ($?) {
return $TRUE
}
return $FALSE
}
if (Jenkins) {
exit 0
}
echo "waiting to see if any jobs are coming in..."
timeout 30
if (Jenkins) {
exit 0
}
echo "doing it"
taskkill /IM putty.exe
taskkill /F /IM java.exe
Get-VM | Where-Object {$_.Name -ne "DockerDesktopVM"} | Foreach {
C:\var\jenkins\workspace\Hyper-V_Windows_integration\out\minikube-windows-amd64.exe delete -p $_.Name
Suspend-VM $_.Name
Stop-VM $_.Name -Force
Remove-VM $_.Name -Force
}
Remove-Item -path C:\Users\admin\.minikube -recurse -force
shutdown /r

View File

@ -0,0 +1,30 @@
function Jenkins {
Get-Process e2e-windows-amd64 2>$NULL
if ($?) {
return $TRUE
}
return $FALSE
}
if (Jenkins) {
exit 0
}
echo "waiting to see if any jobs are coming in..."
timeout 30
if (Jenkins) {
exit 0
}
echo "doing it"
taskkill /IM putty.exe
taskkill /F /IM java.exe
VBoxManage list vms | Foreach {
$m = $_.Substring(1, $_.LastIndexOf('"')-1)
VBoxManage controlvm $m poweroff
VBoxManage unregistervm $m --delete
}
Remove-Item -path C:\Users\jenkins\.minikube -recurse -force
shutdown /r