I’m seeking assistance in exploring a command line solution to retrieve a list of work items / tasks from Azure Boards. I’ve experimented with az boards query, but encountered limitations in aligning it with my requirements. Specifically, I aim to filter work items / tasks based on a portion of their Product Backlog Item title or description, which would list all relevant items that match the criteria.
Here’s an example of the command I’ve tried:
az boards query --org "https://dev.azure.com/jdialmgr/" -p JDATA --wiql "SELECT [State], [Title] FROM WorkItems WHERE [System.Title] = 'UAT Validation'"
However, I received a message indicating that the Azure DevOps Extension for the Azure CLI doesn't support Azure DevOps Server
.
Additionally, I’m interested in discovering if there’s a CLI method to manage pipeline history, particularly to retain only the latest 10 runs while removing older histories. Any insights or suggestions would be greatly appreciated.
2
Answers
To retrieve work items from Azure Boards that match a specific string in their title or description, you can use the
az boards work-item list
command combined with a WIQL (Work Item Query Language). Below is an example that filters work items based on the title containing "UAT Validation":To manage pipeline history and retain only the latest 10 runs
Coming to your point- However, I received a message indicating that the Azure DevOps Extension for the Azure CLI doesn’t support Azure DevOps Server.
This indicates that you’re trying to use the Azure DevOps Extension for Azure CLI with Azure DevOps Server (formerly known as Team Foundation Server or TFS), which is not supported. The Azure CLI with the Azure DevOps extension is designed to interact with Azure DevOps Services (the cloud service), not Azure DevOps Server (the on-premises version).
Would request you to ensure you are indeed trying to connect to Azure DevOps Services and not Azure DevOps Server. The Azure DevOps CLI extension doesn’t support the on-premises version. Also update the CLI, using.
References:
It is strongly recommended setting the retention policies for the pipelines to manage the histories of runs/builds of YAML/build pipelines and releases of release pipelines. See the documentation "Set retention policies".
There are no available Azure CLI commands for Azure Pipelines to delete the retained runs/builds and releases from histories. If you want to delete them via scripts, you can try to call the following REST API in your scripts:
Use the API "Builds – Delete" to delete runs/builds of YAML/build pipelines.
There also is no documented public API to delete releases of release pipelines (see "Releases – REST API"). However, you can try the API below. It’s fetched from the "
Developer tools
" window (press F12) of the browser when manually deleting a release.Before deleting a run/build of YAML/build pipeline, you need to ensure the retention leases on this run/build have been removed. Otherwise, you cannot delete it.