Skip to content

Commit b6e6467

Browse files
committed
CI: chekc for update count via guest.run
Previous incarnations of the script relied on `guest.start` and then fetching the resultant exit code via `guest.ps`. This appears to sometimes not retrun any `exitCode` in some cases. This commit switches to using `guest.run` which is a synchronous command that returns the exit code.
1 parent 89deb66 commit b6e6467

File tree

1 file changed

+10
-6
lines changed
  • ci/tasks/install-windows-updates

1 file changed

+10
-6
lines changed

ci/tasks/install-windows-updates/run.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ $VCENTER_CA_CERT
1111
END_OF_CERT
1212
export GOVC_TLS_CA_CERTS=ca.crt
1313

14-
vm_ipath=${STEMBUILD_CONSTRUCT_TARGET_VM}
1514
vm_username="${VM_USERNAME}"
1615
vm_password="${VM_PASSWORD}"
1716

17+
vm_ipath=${STEMBUILD_CONSTRUCT_TARGET_VM}
18+
powershell_exe="\\Windows\\System32\\WindowsPowerShell\\V1.0\\powershell.exe"
19+
1820
function start_powershell_command() {
1921
local powershell_command="${1}"
2022

2123
echo "Starting '${powershell_command}'" >&2
2224
govc guest.start \
2325
-vm.ipath="${vm_ipath}" \
2426
-l="${vm_username}:${vm_password}" \
25-
"\\Windows\\System32\\WindowsPowerShell\\V1.0\\powershell.exe" \
27+
"${powershell_exe}" \
2628
"${powershell_command}"
2729
}
2830

@@ -79,11 +81,13 @@ function wait_for_vm_to_come_up() {
7981
}
8082

8183
function get_windows_updates_remaining() {
82-
echo "Checking for updates remaining (via exit code of 'guest.ps')..." >&2
83-
# run powershell command that "exits" with the Count returned by Get-WindowsUpdate
84-
get_update_count_pid="$(start_powershell_command "exit (([array](Get-WindowsUpdate)).Count)")"
84+
echo "Checking for updates remaining (via exit code of 'guest.run')..." >&2
8585

86-
get_powershell_pid_exit_code "${get_update_count_pid}"
86+
govc guest.run \
87+
-vm.ipath="${vm_ipath}" \
88+
-l="${vm_username}:${vm_password}" \
89+
"${powershell_exe}" \
90+
"(Get-WindowsUpdate).Count"
8791
}
8892

8993
wait_for_vm_to_come_up

0 commit comments

Comments
 (0)