წაკითხვა ინგლისურად რედაქტირება

გაზიარება არხიდან:


Promote packages and manage feed views

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Feed views enable developers to control package visibility by sharing some packages while keeping others private. Each view filters the feed to display a subset of packages based on specific criteria defined for that view.

By default, Azure Artifacts comes with three views: @Local, @Prerelease, and @Release. The @Local view is the default and contains all published packages and those saved from upstream sources. All views support NuGet, npm, Maven, Python, Cargo, and Universal Packages. You can change the default view in your Feed Settings > Views, but doing so doesn't enable direct publishing to that view. Packages can only be published to the base feed, where they're available in the @Local view.

Note

You must be a Feed Publisher (Contributor) or a Feed Owner to promote packages to a view.

Promote a package to a specific view

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select your feed from the dropdown menu.

  3. Select the package you want to promote, and then select Promote.

  4. Select a view from the dropdown menu, and then select Promote again.

    A screenshot showing the list of available views.

მნიშვნელოვანი

Azure Artifacts doesn't support package demotion. Once a package is promoted, it can't be reverted to a previous view.

Promote a package using the REST API

To promote a package using the REST API, you need to send a PATCH request with the appropriate body formatted as a JSON Patch document. This appends the desired view (for example, Prerelease) to the package’s views array.

  1. Create a Personal Access Token with Packaging > Read, write, & manage scope.

  2. Copy the endpoint URL, replace it in the following example (either PowerShell or curl), and run the command to promote your package to the desired view.

  • Organization scoped feed:

    HTTP
    https://pkgs.dev.azure.com/{organization}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}?api-version=7.1
    
  • Project scoped feed:

    HTTP
    https://pkgs.dev.azure.com/{organization}/{project}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}?api-version=7.1
    

See JsonPatchOperation and NuGet - Update Package Version for more details.

  • Collection scoped feed:

    HTTP
    https://{instance}/{collection}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}?api-version=7.1
    
  • Project scoped feed:

    HTTP
    https://{instance}/{collection}/{project}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}?api-version=7.1
    

See JsonPatchOperation and NuGet - Update Package Version for more details.

  • Collection scoped feed:

    HTTP
    https://{instance}/{collection}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}?api-version=6.0-preview.1
    
  • Project scoped feed:

    HTTP
    https://{instance}/{collection}/{project}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}?api-version=6.0-preview.1
    

See JsonPatchOperation and NuGet - Update Package Version for more details.

Examples

Replace the placeholders with your personal access token, endpoint URL, and view name, then run the command to promote your package to the desired view:

PowerShell
$env:PAT = "YOUR_PERSONAL_ACCESS_TOKEN"
$uri = "YOUR_URL"
$headers = @{
    "Content-Type" = "application/json"
    Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$env:PAT"))
}
$body = @{
    views = @{
        op    = "add"
        path  = "/views/-"
        value = "YOUR_VIEW_NAME"
    }
} | ConvertTo-Json

Invoke-RestMethod -Uri $uri -Method Patch -Headers $headers -Body $body

Note

All feed views in a public project are accessible to everyone on the internet.

Manage views

By default, Azure Artifacts offers three views: @Local, @Prerelease, and @Release. You can also create new views and manage existing ones by renaming or deleting them directly from your feed's settings.

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select your feed from the dropdown menu.

  3. Select the gear icon on the far right to access your feed's settings.

    Screenshot showing how to access the feed's settings.

  4. Select Views, select a view, and then select Edit to edit your view. If you want to add a new view, select Add view.

    A screenshot showing how to add, edit, or delete feed views.

  5. Select Save when you're done.

მნიშვნელოვანი

For public feeds, if you change the access permissions of a view to Specific people, that view is no longer available as an upstream source.