microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
381 stars 243 forks source link

Devops Pipeline based on Hands On Lab failing #3506

Closed MUR-SDP closed 4 months ago

MUR-SDP commented 4 months ago

Describe the issue

We are in the process of implementing AL-GO for github but for the moment we use Azure Devops with a Pipeline that's based on the original Hands On Lab as per Freddy's Blog. When doing a Pull Request this afternoon, the pipeline failed and we cannot get it to run through.

Scripts used to create container and cause the issue Settings.Json: { "name": "BC VIP Implementation", "memoryLimit": "6G", "installApps": "", "installTestApps": "", "previousApps": "", "appFolders": "app,base", "testFolders": "test", "installTestRunner": true, "installTestFramework": false, "installTestLibraries": false, "installPerformanceToolkit": false, "doNotSignApps": true, "doNotRunTests": true, "enableCodeCop": false, "enableAppSourceCop": false, "enablePerTenantExtensionCop": true, "enableUICop": true, "bcContainerHelperVersion": "preview", "additionalCountries": "", "vaultNameForLocal": "BuildVariables", "versions": [ { "version": "ci", "artifact": "///w1/SecondToLastMajor", "cacheImage": true, "CreateRuntimePackages": true }, { "version": "current", "artifact": "///w1/SecondToLastMajor", "CreateRuntimePackages": true }, { "version": "cloud", "artifact": "///w1/SecondToLastMajor" }, { "version": "nextmajor", "artifact": "///w1/NextMajor/{INSIDERSASTOKEN}" }, { "version": "nextminor", "artifact": "///w1/NextMinor/{INSIDERSASTOKEN}" } ] }

DevOps-Pipeline.ps1:

Param( [Parameter(Mandatory=$false)] [ValidateSet('AzureDevOps','GithubActions','GitLab')] [string] $environment = 'AzureDevOps', [Parameter(Mandatory=$true)] [string] $version, [Parameter(Mandatory=$false)] [int] $appBuild = 0, [Parameter(Mandatory=$false)] [int] $appRevision = 0 )

if ($environment -eq "AzureDevOps") { $buildArtifactFolder = $ENV:BUILD_ARTIFACTSTAGINGDIRECTORY } elseif ($environment -eq "GitHubActions") { $buildArtifactFolder = Join-Path $ENV:GITHUB_WORKSPACE "output" New-Item $buildArtifactFolder -ItemType Directory | Out-Null }

$baseFolder = (Get-Item (Join-Path $PSScriptRoot "..")).FullName . (Join-Path $PSScriptRoot "Read-Settings.ps1") -environment $environment -version $version . (Join-Path $PSScriptRoot "Install-BcContainerHelper.ps1") -bcContainerHelperVersion $bcContainerHelperVersion -genericImageName $genericImageName

$authContext = $null $refreshToken = "$($ENV:BcSaasRefreshToken)" $environmentName = "$($ENV:EnvironmentName)" if ($refreshToken -and $environmentName) { $authContext = New-BcAuthContext -refreshToken $refreshToken if (Get-BcEnvironments -bcAuthContext $authContext | Where-Object { $.Name -eq $environmentName -and $.type -eq "Sandbox" }) { Remove-BcEnvironment -bcAuthContext $authContext -environment $environmentName } $countryCode = $artifact.Split('/')[3] New-BcEnvironment -bcAuthContext $authContext -environment $environmentName -countryCode $countrycode -environmentType "Sandbox" | Out-Null do { Start-Sleep -Seconds 10 $baseApp = Get-BcPublishedApps -bcAuthContext $authContext -environment $environmentName | Where-Object { $_.Name -eq "Base Application" } } while (!($baseApp)) $baseapp | Out-Host

$artifact = Get-BCArtifactUrl `
    -country $countryCode `
    -version $baseApp.Version `
    -select Closest

if ($artifact) {
    Write-Host "Using Artifacts: $artifact"
}
else {
    throw "No artifacts available"
}

}

$params = @{} $insiderSasToken = "$ENV:insiderSasToken" $licenseFile = "$ENV:licenseFile" $codeSigncertPfxFile = "$ENV:CodeSignCertPfxFile" if (!$doNotSignApps -and $codeSigncertPfxFile) { if ("$ENV:CodeSignCertPfxPassword" -ne "") { $codeSignCertPfxPassword = try { "$ENV:CodeSignCertPfxPassword" | ConvertTo-SecureString } catch { ConvertTo-SecureString -String "$ENV:CodeSignCertPfxPassword" -AsPlainText -Force } $params = @{ "codeSignCertPfxFile" = $codeSignCertPfxFile "codeSignCertPfxPassword" = $codeSignCertPfxPassword } } else { $codeSignCertPfxPassword = $null } }

$allTestResults = "testresults*.xml" $testResultsFile = Join-Path $baseFolder "TestResults.xml" $testResultsFiles = Join-Path $baseFolder $allTestResults if (Test-Path $testResultsFiles) { Remove-Item $testResultsFiles -Force }

Run-AlPipeline @params -pipelinename $pipelineName -containerName $containerName -imageName $imageName -bcAuthContext $authContext -environment $environmentName -artifact $artifact.replace('{INSIDERSASTOKEN}',$insiderSasToken) -memoryLimit $memoryLimit -baseFolder $baseFolder -installApps $installApps -installTestApps $installTestApps -previousApps $previousApps -appFolders $appFolders -testFolders $testFolders -doNotRunTests:$doNotRunTests -testResultsFile $testResultsFile -testResultsFormat 'JUnit' -installTestRunner:$installTestRunner -installTestFramework:$installTestFramework -installTestLibraries:$installTestLibraries -installPerformanceToolkit:$installPerformanceToolkit -enableCodeCop:$enableCodeCop -enableAppSourceCop:$enableAppSourceCop -enablePerTenantExtensionCop:$enablePerTenantExtensionCop -enableUICop:$enableUICop -azureDevOps:($environment -eq 'AzureDevOps') -gitLab:($environment -eq 'GitLab') -gitHubActions:($environment -eq 'GitHubActions') -failOn 'error' -AppSourceCopMandatoryAffixes $appSourceCopMandatoryAffixes -AppSourceCopSupportedCountries $appSourceCopSupportedCountries -additionalCountries $additionalCountries -buildArtifactFolder $buildArtifactFolder -CreateRuntimePackages:$CreateRuntimePackages -appBuild $appBuild -appRevision $appRevision

if ($environment -eq 'AzureDevOps') { Write-Host "##vso[task.setvariable variable=TestResults]$allTestResults" }

Full output of scripts

Starting: Run Pipeline

Task : PowerShell Description : Run a PowerShell script on Linux, macOS, or Windows Version : 2.237.5 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell

Generating script. Formatted command: . 'D:\a\1\s\scripts\DevOps-Pipeline.ps1' -environment "AzureDevOps" -version "ci" -appBuild 1726 -appRevision 0 ========================== Starting Command Output =========================== "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a_temp\96cd7432-31b5-4807-8e7f-9536a0149bf8.ps1'" Set artifact = ///w1/SecondToLastMajor Set pipelineName = BC VIP Implementation-ci Set containerName = hostedagent-bcvipimplementation-ci Set installApps = '' Set installTestApps = '' Set previousApps = '' Set appSourceCopMandatoryAffixes = '' Set appSourceCopSupportedCountries = '' Set appFolders = 'app,base' Set testFolders = 'test' Set memoryLimit = '6G' Set additionalCountries = '' Set genericImageName = '' Set vaultNameForLocal = 'BuildVariables' Set bcContainerHelperVersion = 'SecondToLastMajor' Set installTestRunner = True Set installTestFramework = False Set installTestLibraries = False Set installPerformanceToolkit = False Set enableCodeCop = False Set enableAppSourceCop = False Set enablePerTenantExtensionCop = True Set enableUICop = True Set doNotSignApps = True Set doNotRunTests = True Set cacheImage = True Set CreateRuntimePackages = True

[error]D:\a\1\s\scripts\DevOps-Pipeline.ps1 : Exception calling "DownloadString" with "1" argument(s): "The remote name could

not be resolved: 'bccontainerhelper.azureedge.net'" At D:\a_temp\96cd7432-31b5-4807-8e7f-9536a0149bf8.ps1:4 char:1

Additional context

This used to work until 3 days ago when we last did a Pull Request. Today it is failing, and our Pipelines are not working anymore. We are using Business Central Cloud version 23.5.16502.16589.

Appreciate the help!!

freddydk commented 4 months ago

https://github.com/microsoft/navcontainerhelper/issues/3499