pizycki
pizycki

Reputation: 1350

How to delete unwanted artifacts in Azure DevOps

Our developer teams produce many NuGet packages which are published to Azure DevOps Artifacts feed. Most of them become unwanted over a week or two.

How can I select which artifacts should be covered with retention? Azure provides only general configuration, basically allowing only to specify a time after which artifacts will be retained. I was thinking about some sort of job which would select artifacts that match my criteria and delete them, but I'm afraid Azure DevOps REST API does not provide such functionality as Artifact deletion.

For example, I'd like to cover all pre-release packages with retention policy.

You can check your artifacts storage here (mind the placeholder) https://dev.azure.com/<org>/_settings/storage

Some external resources:

Upvotes: 4

Views: 25205

Answers (3)

Luca Ritossa
Luca Ritossa

Reputation: 1185

I have a similar issue in my company.

Preface

We develop a product composed by numerous projects (.csproj) in the same Visual Studio Solution (.sln).
Each of these projects generates a NuGet package.
We use GitVersion to automatically versioning our assemblies and NuGet packages. So when we release a new version these packages are versioned with the same number.

Often we need to publish a pre-release version and use it to develop other solutions based on our product, waiting for the official release.
These pre-release then became old and unwanted when we release the official version of our product.

Now we have a lot of unwanted pre-release packages that affect the size of our Azure DevOps Artifacts feed.
We intentionally don't want to use retention policy because doesn't fit our needs.

My solution: DevOps Artifacts Cleaner

I know I can directly delete these packages from Azure DevOps website but this is a tedious task since I'd like to delete all packages that have the same version with only a few clicks.

This not completely reply to your question but I’d like to inform you that I just started a new open-source project in GitHub called DevOps Artifacts Cleaner

It is a Windows Forms application tool based on .NET8 that tries to simplify and speed up actions like UNLIST/RELIST and DELETE of packages versions with the help of some filters (by name, by official/pre release and by listed/unlisted)

This tool has been developed in my spare time and, for the moment, has few features but I hope it can grow thanks to the community.

I leave here a screenshot: DevOps Artifacts Cleaner

Upvotes: 2

Josh Withee
Josh Withee

Reputation: 11376

To delete all versions of an artifact at once: Go to the feed, then to the artifact, then click the Versions tab, then check all the boxes, and delete them as shown in the screenshot below:

enter image description here

Upvotes: 1

Hugh Lin
Hugh Lin

Reputation: 19461

The rest api you mentioned in the question is about build artifacts, the artifacts are the files that you want your build to produce. Please refer to this document.

I think what you actually need is Delete Feed rest api. This rest api can remove a feed and all its packages. Note: The action does not result in packages moving to the RecycleBin and is not reversible.

DELETE https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/feeds/{feedId}?api-version=5.1-preview.1

To delete a package ,you can use NuGet - Delete Package Version rest api. Send a package version from the feed to its paired recycle bin.

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

Upvotes: 4

Related Questions