Clean up background processes on CI builds (#11151)

Addresses issues where background Java processes causes builds to hang.
Added diagnostics to capture running processes on CI builds.
This commit is contained in:
John Luo 2019-06-13 12:48:23 -07:00 коммит произвёл GitHub
Родитель b0be780f1b
Коммит 3707e1a832
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,4 @@
@ECHO OFF
SETLOCAL
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; try { & '%~dp0build.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }"
PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; try { & '%~dp0build.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }"
ECHO build.cmd completed

Просмотреть файл

@ -124,6 +124,9 @@ param(
# MSBuild for .NET Core
[switch]$ForceCoreMsbuild,
# Diagnostics
[switch]$DumpProcesses, # Capture all running processes and dump them to a file.
# Other lifecycle targets
[switch]$Help, # Show help
@ -243,6 +246,12 @@ $env:DOTNET_HOME = $DotNetHome
# Execute
if ($DumpProcesses -or $CI)
{
# Dump running processes
Start-Job -Name DumpProcesses -FilePath $PSScriptRoot\eng\scripts\dump_process.ps1 -ArgumentList $PSScriptRoot
}
$korebuildPath = Get-KoreBuild
# Project selection
@ -372,4 +381,16 @@ finally {
Remove-Module 'KoreBuild' -ErrorAction Ignore
Remove-Item env:DOTNET_HOME
Remove-Item env:KOREBUILD_KEEPGLOBALJSON
if ($DumpProcesses -or $CI)
{
Stop-Job -Name DumpProcesses
Remove-Job -Name DumpProcesses
}
if ($CI) {
& "$PSScriptRoot/eng/scripts/KillProcesses.ps1"
}
Write-Host "build.ps1 completed"
}

Просмотреть файл

@ -1,3 +1,4 @@
@ECHO OFF
SET RepoRoot=%~dp0..\..
%RepoRoot%\build.cmd -ci -all -pack -sign %*
ECHO cibuild.cmd completed

Просмотреть файл

@ -0,0 +1,9 @@
Set-Location $args[0]
$timestamp = $(get-date -f MM-dd-HH-mm)
while ($true) {
Get-Process > artifacts/log/runningProcesses.$timestamp.txt
Get-WmiObject Win32_Process | select name, processid, commandline > artifacts/log/runningProcessesCommandLine.$timestamp.txt
Start-Sleep -Seconds 300
}

Просмотреть файл

@ -1,3 +1,3 @@
@ECHO OFF
SETLOCAL
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' -all -nobuild -restore %*; exit $LASTEXITCODE"
PowerShell -NoProfile -NoLogo -ExecutionPolicy ByPass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' -all -nobuild -restore %*; exit $LASTEXITCODE"