Azure DevOps Build Cleanup: Automatically Delete Old Version Check Pipelines
Published 07/07/2026
Description
In this video, I show how to clean up an Azure DevOps build pipeline after running recurring version checks for outdated NuGet or package dependencies. If you already have a daily, weekly, or monthly Azure DevOps pipeline that checks whether your packages are up to date, your build history can quickly become cluttered with old runs that no longer matter. Contents: 0:00 - Introduction 0:45 - Description 1:47 - Build Pipeline 3:13 - PAT 6:06 - The Code 11:15 - Run 13:03 - Automate 14:04 - Conclusion I walk through a simple approach to automatically delete all older builds while keeping only the latest result. The tutorial also covers how to handle retention leases, create a Personal Access Token PATPAT with the correct permissions, connect to Azure DevOps Server or Azure DevOps Services, and automate the cleanup process with Windows Task Scheduler. In this Azure DevOps tutorial, you will learn how to: Create a PAT for pipeline cleanup. Retrieve build definitions programmatically. Filter version-check pipelines. Remove retention leases before deleting successful builds. Delete all non-latest builds automatically. Schedule the cleanup job to run regularly. This is a practical way to keep your Azure DevOps environment clean, focused, and easier to manage, especially when your version-check pipelines run frequently and you only care about the most recent status. If you enjoy practical Azure DevOps and automation content, make sure to like, subscribe, and leave a comment with how you manage build retention in your own environment. #AzureDevOps #DevOps #BuildPipeline GitHub: https://l.samayas.eu/9D6eRrLY0F Follow me on X: https://l.samayas.eu/jo3eaYEf3E?P=YT&V=132 Buy me a Coffee : https://l.samayas.eu/jX6xL7EWhd?P=YT&V=132 Studio Equipment Camera Sony Alpha ZV-E10 II: https://l.samayas.eu/k7y95TREl0?P=YT&V=132 Secondary Camera Obsbot Tail Air: https://l.samayas.eu/iFQu9WfmCw?P=YT&V=132 Elgato Prompter: https://l.samayas.eu/fHVrqq