azure-sdk-for-cpp/eng/scripts/Show-FailureLogs.ps1
Daniel Jurek caa3010ece
Harden Show-FailureLogs.ps1 against failures where the files are not present between Get-ChildItem and the output of the file (#5454)
* Harden Show-FailureLogs.ps1 against failures where the files are not present between Get-ChildItem and the output of the file

* Also log .FullName
2024-05-06 22:44:34 +00:00

32 lines
1.2 KiB
PowerShell

# Only show contents of particular vcpkg log files whose potentially sensitive
# information will be redacted by DevOps (if it's included).
# Before adding other expressions to output ensure that those logs will not
# contain sensitive information or that DevOps is properly configured to remove
# sensitive information.
$logFiles = Get-ChildItem -Recurse -Filter *.log
$filteredLogs = $logFiles.Where({ $_.Name -in ('vcpkg-bootstrap.log', 'vcpkg-manifest-install.log') })
$filteredLogs.FullName | Write-Host
if (!$filteredLogs) {
Write-Host "No logs found"
exit 0
}
foreach ($logFile in $filteredLogs)
{
Write-Host "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
Write-Host "=============================================================================================================================="
Write-Host "Log file: $logFile"
Write-Host "=============================================================================================================================="
try {
Get-Content $logFile | Write-Host
} catch {
Write-Host "Could not locate file found using Get-ChildItem $logFile"
}
}
exit 0