File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,7 +143,24 @@ Describe 'Organizations' {
143143 }
144144
145145 It ' Install-GitHubApp - Installs a GitHub App to an organization' - Skip:($OwnerType -ne ' enterprise' ) {
146- $installation = Install-GitHubApp - Enterprise $owner - Organization $orgName - ClientID $installationContext.ClientID - RepositorySelection ' all'
146+ # The enterprise organization was just created and may not have propagated to the
147+ # enterprise apps endpoint yet. Retry briefly to absorb propagation delay before
148+ # failing — GitHub returns 404 (rather than 403) when the resource is not yet visible
149+ # to the token, which is indistinguishable from a missing-permission failure on the
150+ # first call. See issue #596.
151+ $installation = $null
152+ $maxAttempts = 5
153+ $delaySeconds = 3
154+ for ($attempt = 1 ; $attempt -le $maxAttempts ; $attempt ++ ) {
155+ try {
156+ $installation = Install-GitHubApp - Enterprise $owner - Organization $orgName - ClientID $installationContext.ClientID - RepositorySelection ' all'
157+ break
158+ } catch {
159+ if ($attempt -eq $maxAttempts ) { throw }
160+ Write-Host " Install-GitHubApp attempt $attempt failed ($ ( $_.Exception.Message ) ); retrying in $delaySeconds seconds..."
161+ Start-Sleep - Seconds $delaySeconds
162+ }
163+ }
147164 LogGroup ' Installed App' {
148165 Write-Host ($installation | Select-Object * | Out-String )
149166 }
You can’t perform that action at this time.
0 commit comments