Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall apps after timeout or installation failure #7970

Merged
merged 8 commits into from
Oct 21, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,22 @@ $process.Start()

Wait-Process -InputObject $process -TimeOut $command_timeout -ErrorVariable ev -ErrorAction SilentlyContinue

function Remove-Apps {
$adb_path = dotnet xharness android state --adb
greenEkatherine marked this conversation as resolved.
Show resolved Hide resolved
$packages = & $adb_path shell pm list packages net.dot
$split_packages = $packages.split(':')
For ($i = 1; $i -lt $split_packages.Length; $i += 2) {
echo $split_packages[$i] | %{&$adb_path uninstall $_}
}
}

if ($ev) {
$exit_code = -3
Stop-Process -InputObject $process -Force
$process.WaitForExit()
[Console]::Out.Flush()
Write-Output "User command timed out after $command_timeout seconds!"
$adb_path=dotnet xharness android state --adb
$packages=& $adb_path shell pm list packages net.dot
$split_packages=$packages.split(':')
For ($i=1; $i -lt $split_packages.Length; $i+=2) {
echo $split_packages[$i] | %{&$adb_path uninstall $_}
}
Remove-Apps
} else {
$exit_code = $process.ExitCode
Write-Output "User command ended with $exit_code"
Expand All @@ -77,14 +81,9 @@ switch ($exit_code)
Write-Error "Encountered PACKAGE_INSTALLATION_FAILURE. This is typically not a failure of the work item. We will try it again on another Helix agent"
Write-Error "If this occurs repeatedly, please check for architectural mismatch, e.g. requesting installation on arm64_v8a-only queue for x86 or x86_64 APKs."

$adb_path=dotnet xharness android state --adb
$packages=& $adb_path shell pm list packages net.dot
$split_packages=$packages.split(':')
For ($i=1; $i -lt $split_packages.Length; $i+=2) {
echo $split_packages[$i] | %{&$adb_path uninstall $_}
}
Remove-Apps

$retry=$true
$retry = $true
Break
}
}
Expand Down