ResourceModules icon indicating copy to clipboard operation
ResourceModules copied to clipboard

[Bug Report]: ADO Pipeline publishing to private registry not working

Open msfreaks opened this issue 2 years ago • 1 comments

Describe the bug

While onboarding the pipelines for the modules in Azure DevOps I noticed that the first pipeline completed had deployed the container registry resource, and had published the module to the registry. The second module did not publish to the registry, nor did any subsequent modules.

Expected behavior would have been that all pipelines publish the modules to the registry.

To reproduce

In Azure DevOps configure the environment, add 2 or more module pipelines.

Run 1 of the module pipelines and confirm the registry is deployed and the module for that pipeline is published in the registry. Run another module pipeline and confirm the module for that pipeline is not published in the registry.

Code snippet

No response

Relevant log output

partial log for first module pipeline run (resourceGroups):

VERBOSE: Gathering modified files from the pull request
VERBOSE: Looking for modified files under: [Microsoft.Resources/resourceGroups]
VERBOSE: No template file found in the modified module.
VERBOSE: Modified modules found: [0]
VERBOSE: No modules with changes found to publish.
VERBOSE: Invoke Get-ModulesMissingFromPrivateBicepRegistry with
VERBOSE: {
  "TemplateFilePath": "/home/vsts/work/1/s/modules/Microsoft.Resources/resourceGroups/deploy.bicep",
  "PublishLatest": true,
  "BicepRegistryName": "nubcrcarmleuw",
  "BicepRegistryRgName": "artifacts-rg"
}

VERBOSE: Missing module [/home/vsts/work/1/s/modules/Microsoft.Resources/resourceGroups/deploy.bicep] will be considered for publishing with version(s) [0.5.0, 0.5, 0, latest]
 - [Microsoft.Resources/resourceGroups] [0.5.0]
 - [Microsoft.Resources/resourceGroups] [0.5]
 - [Microsoft.Resources/resourceGroups] [0]
 - [Microsoft.Resources/resourceGroups] [latest]

/usr/bin/az account clear
Finishing: Publish module to private bicep registry


Partial log for second module pipeline run (vaults):
VERBOSE: Gathering modified files from the pull request
VERBOSE: Looking for modified files under: [Microsoft.KeyVault/vaults]
VERBOSE: No template file found in the modified module.
VERBOSE: Modified modules found: [0]
VERBOSE: No modules with changes found to publish.
VERBOSE: Invoke Get-ModulesMissingFromPrivateBicepRegistry with
VERBOSE: {
  "BicepRegistryRgName": "artifacts-rg",
  "TemplateFilePath": "/home/vsts/work/1/s/modules/Microsoft.KeyVault/vaults/deploy.bicep",
  "BicepRegistryName": "nubcrcarmleuw",
  "PublishLatest": true
}

VERBOSE: No modules missing in the target environment
/usr/bin/az account clear
Finishing: Publish module to private bicep registry

msfreaks avatar Apr 12 '23 14:04 msfreaks

I can work around the problem by modifying line 87 in Get-ModulesMissingFromPrivateBicepRegistry.ps1

Change if ($result.exception.Response.StatusCode -eq 'NotFound') {

Into if ($result.Exception.Status -eq '404') {

Reasoning: there is no Response attribute in $result.Exception..

msfreaks avatar Apr 12 '23 14:04 msfreaks