1
votes

I want to use Azure Devops rest apis to get all retained builds of a specific build definition.

Reading Azure Devops documentation I tried this api:

https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions=1

With this I get all build of my build definition '1'.

Each build has the 'keepForever' property. If this has value 'true', that is a retained build.

Usually the retained builds are fewer than non retained. I'd want to have just the retained ones.

I tried to add the 'keepForever=true' query string parameter with no luck.

Is there a way to made the http request to get retained builds only?

Can I avoid to read much data I don't want?

1
This is old, but I came across it before I found another question that provided what I was looking for, so I'm posting a link to it here in case anyone else has the same experience. In How can I delete an Azure DevOps build definition that it claims is retained by a release? the top answer has a PowerShell script that uses the Azure DevOps REST API and filtering to get the list of builds that are retained by a release.Ray Dixon

1 Answers

3
votes

You can find a list of parameters here: Builds - List - URI Parameters. There is no keepForever in that list and no any additional filter options for this parameter. As workaround, you may try to set some tag for retained builds and then use tagFilters parameter. But that maybe more complex way than filter keepForever property with your code.