azure-devops-cli-extension icon indicating copy to clipboard operation
azure-devops-cli-extension copied to clipboard

NuGet package promotion fails using 'az devops invoke'

Open stefanes opened this issue 4 years ago • 4 comments

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.

  • az devops invoke --api-version 6.1-preview --area nuget --org {org} --resource Versions --route-parameters feedId={feedId} packageName={packageName} packageVersion={packageVersion} --http-method PATCH --in-file body.json --output json
  • body.json:
{
    "views" : {
        "op" : "add",
        "path" : "/views/-",
        "value" : "{viewId}"
    }
}

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

stefanes avatar Oct 26 '20 11:10 stefanes

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

salih18 avatar May 25 '22 23:05 salih18

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.

stefanes avatar May 30 '22 15:05 stefanes

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

chris-pateman avatar Jun 24 '22 08:06 chris-pateman

Can confirm having the same issue. Any workarounds?

dbeusink avatar Jan 15 '24 08:01 dbeusink