Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retries when running git fetch #2405

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mazhelez
Copy link
Contributor

@mazhelez mazhelez commented Nov 26, 2024

Issue:
Builds sometimes fail with:

Error: Unexpected error when running action. Error Message: Unable to find repoVersion in AL-Go-Settings.json, StackTrace: at Get-MaxAllowedObsoleteVersion, D:\a\BCApps\BCApps\build\scripts\GuardingV2ExtensionsHelper.psm1: line 264 <- at Update-AppSourceCopVersion, D:\a\BCApps\BCApps\build\scripts\GuardingV2ExtensionsHelper.psm1: line 208 <- at Enable-BreakingChangesCheck, D:\a\BCApps\BCApps\build\scripts\GuardingV2ExtensionsHelper.psm1: line 67 <- at <ScriptBlock>, D:\a\BCApps\BCApps\build\scripts\PreCompileApp.ps1: line 63 <- at <ScriptBlock>, D:\a\BCApps\BCApps\build\projects\System Application\.AL-Go\PreCompileApp.ps1: line 7 <- at <ScriptBlock>, C:\ProgramData\BcContainerHelper\6.0.29-preview1267\BcContainerHelper\AppHandling\Run-AlPipeline.ps1: line 2070 <- at <ScriptBlock>

The underlying error is

  fatal: unable to access 'https://github.com/microsoft/BCApps/': Recv failure: Connection was aborted
  fatal: invalid object name 'origin/main'.

or sometimes

  fatal: unable to access 'https://github.com/microsoft/BCApps/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0
  fatal: invalid object name 'origin/main'.

Solution:
Add retries when running git fetch to catch the instability.

Fixes AB#557642

@mazhelez mazhelez requested a review from a team as a code owner November 26, 2024 09:26
@github-actions github-actions bot added the Build: scripts & configs Build scripts and configuration files label Nov 26, 2024
@github-actions github-actions bot added this to the Version 26.0 milestone Nov 26, 2024
@mazhelez mazhelez changed the title Fetch .github/AL-Go-Settings.json from the local main branch, instead of the remote Add retries when running git fetch Nov 26, 2024
$retryNo++
try {
Invoke-Command -ScriptBlock $ScriptBlock -OutVariable output | Out-Null
return $output # Success!

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Invoke-CommandWithRetry' returns an object of type 'System.String' but this type is not declared in the OutputType attribute. Note

The cmdlet 'Invoke-CommandWithRetry' returns an object of type 'System.String' but this type is not declared in the OutputType attribute.
git fetch origin main
$alGoSettings = $(git show origin/main:.github/AL-Go-Settings.json) | ConvertFrom-Json
Import-Module -Name $PSScriptRoot\EnlistmentHelperFunctions.psm1

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build: scripts & configs Build scripts and configuration files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant