Azure / azure-devops-cli-extension

Azure DevOps Extension for Azure CLI
https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/?view=azure-cli-latest
MIT License
623 stars 241 forks source link

NuGet package promotion fails using 'az devops invoke' #1063

Open stefanes opened 3 years ago

stefanes commented 3 years ago

Describe the bug

Adding a NuGet package to a view fails using az devops invoke. Using --area nuget seems to direct the call to artifacts.dev.azure.com instead of pkgs.dev.azure.com causing the command to fail.

Is this caused by duplicate nuget areas listed by https://dev.azure.com/{org}/_apis/ResourceAreas (one referencing artifacts.dev.azure.com, and one referencing pkgs.dev.azure.com)? Or how can I make the command go look at the correct area?

az devops invoke --org {org} --query "[?area=='nuget' && resourceName=='Versions']":

[
  {
    "area": "nuget",
    "id": "36c9353b-e250-4c57-b040-513c186c3905",
    "maxVersion": 6.1,
    "minVersion": 2.0,
    "releasedVersion": "0.0",
    "resourceName": "Versions",
    "resourceVersion": 1,
    "routeTemplate": "{project}/_apis/packaging/feeds/{feedId}/{area}/packages/{packageName}/{resource}/{packageVersion}"
  }
]

REST API: https://docs.microsoft.com/en-us/rest/api/azure/devops/artifactspackagetypes/nuget/update%20package%20version?view=azure-devops-rest-6.1

Command Name az devops invoke Extension Name: azure-devops. Version: 0.18.0.

Errors:

ValidationError: --resource and --api-version combination is not correct

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Package is added to the provided view.

Environment Summary

Windows-10-10.0.16299-SP0
Python 3.6.8
Installer: MSI

azure-cli 2.12.1

Extensions:
azure-devops 0.18.0

Additional Context

salih18 commented 2 years ago

I think you forgot to pass {project} name like this --route-parameters project=xxxxx in your script.

stefanes commented 2 years ago

I think you forgot to pass {project} name like this --route-parameters project=xxxxx in your script.

This is an organisation scoped feed, so the {project} parameter should not be supplied.

chris-pateman commented 2 years ago

The issue is the area nuget is not unquie. if you do GET https://dev.azure.com/hmcts/_apis/ResourceAreas you will find two.

the az devops invoke will choose the first it finds which is

{
        "id": "9d3a4e8e-2f8f-4ae1-abc2-b461a51cb3b3",
        "name": "nuget",
        "locationUrl": "https://artifacts.dev.azure.com/hmcts/"
    }

This is not the one I guess you want, as I am having the same issue.

{
        "id": "b3be7473-68ea-4a81-bfc7-9530baaa19ad",
        "name": "nuget",
        "locationUrl": "https://pkgs.dev.azure.com/hmcts/"
    }

This means the Resouce doesn't match. if you add --debug at the end you can see the request`

bug has been raised here https://github.com/Azure/azure-devops-cli-extension/issues/1012

dbeusink commented 8 months ago

Can confirm having the same issue. Any workarounds?