mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 03:57:32 +00:00
[Ubuntu] Add verbosity during software report generation (#4811)
* Add verbosity during software report generation * Fix Get-CpanVersion * set default ValidateExitCode value to $true * update java test * use lower-case for parameters
This commit is contained in:
committed by
GitHub
parent
bb56fb7ef4
commit
92eeb55189
@@ -2,11 +2,27 @@ function Get-CommandResult {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Command,
|
||||
[switch] $Multiline
|
||||
[int[]] $ExpectExitCode = 0,
|
||||
[switch] $Multiline,
|
||||
[bool] $ValidateExitCode = $true
|
||||
)
|
||||
|
||||
# Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version")
|
||||
$stdout = & bash -c "$Command 2>&1"
|
||||
$exitCode = $LASTEXITCODE
|
||||
|
||||
if ($ValidateExitCode) {
|
||||
if ($ExpectExitCode -notcontains $exitCode) {
|
||||
try {
|
||||
throw "StdOut: '$stdout' ExitCode: '$exitCode'"
|
||||
} catch {
|
||||
Write-Host $_.Exception.Message
|
||||
Write-Host $_.ScriptStackTrace
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return @{
|
||||
Output = If ($Multiline -eq $true) { $stdout } else { [string]$stdout }
|
||||
ExitCode = $exitCode
|
||||
|
||||
Reference in New Issue
Block a user