mirror of
https://github.com/actions/runner-images.git
synced 2025-12-19 00:06:57 +00:00
Helper function for execution of xcversion with more than one attempt. (#2700)
* Invoke-XCVersion function has been created
* PR Comments resolving
* $result.Output | ForEach-Object { Write-Host $_ } has been added
* $PauseDuration -> $PauseDurationSecs
* Fixing the attempt indexing
This commit is contained in:
@@ -121,4 +121,34 @@ function Get-XcodePairsList {
|
||||
$result += "$watchName $phoneName"
|
||||
}
|
||||
return $result
|
||||
}
|
||||
|
||||
#Helper function for execution of xcversion due to: https://github.com/fastlane/fastlane/issues/18161
|
||||
function Invoke-XCVersion {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Arguments,
|
||||
[Parameter()]
|
||||
[int] $RetryAttempts = 7,
|
||||
[Parameter()]
|
||||
[int] $PauseDurationSecs = 1
|
||||
)
|
||||
|
||||
$Command = "xcversion $Arguments"
|
||||
Write-Host "Execute [$Command]"
|
||||
for ($Attempt=1; $Attempt -le $RetryAttempts; $Attempt++) {
|
||||
Write-Host "Current attempt: [$Attempt]"
|
||||
$result = Get-CommandResult -Command $Command -Multiline
|
||||
Write-Host "Exit code: [$($result.ExitCode)]"
|
||||
Write-Host "Output message: "
|
||||
$result.Output | ForEach-Object { Write-Host $_ }
|
||||
if ($result.ExitCode -ne 0) {
|
||||
Start-Sleep -Seconds $PauseDurationSecs
|
||||
} else {
|
||||
return $result.Output
|
||||
}
|
||||
}
|
||||
if ($result.ExitCode -ne 0) {
|
||||
throw "Command [$Command] has finished with non-zero exit code."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user