-1

Is there a way to download all files with a specific name from the master branches of all the projects in an Azure DevOps installation?

I have been tasked with documenting all of the entries in all of the appsettings.json files in our entire codebase and I would prefer to not have to go through all 300 repositories to manually download these files if I don't absolutely have to.

Tony Sullivan
  • 45
  • 1
  • 9

1 Answers1

0

Is there a way to download all files with a specific name from the master branches of all the projects in an Azure DevOps installation?

This is not supported. Please check this document, we recommend different project(with one or more repos) for different products/sub-modules of big product. So in Azure Devops Service there's no such out-of-box feature to find/download files across projects.

A possible direction:

If those appsettings.json files are in root directory of your repos. You may save some time by using these two Rest APIs:

List all repos in current organization:

GET https://dev.azure.com/{OrganizationName}/_apis/git/repositories?api-version=5.1

Get File(Download):

GET https://dev.azure.com/{OrganizationName}/_apis/git/repositories/{Repositoryid}/items?scopePath=/appsettings.json&download=true&api-version=5.1

You can use PowerShell script to combine these two apis. The first one will list all Repositoryids in your organization, and the second one can download the appsettings.json from different repos via different Repositoryids. So the possible way could be run the first api once to get list of reposID(You can check this similar one) and then add a loop to get the files one by one.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Thank you very much for the answer. I was able to use the repositiories API and the trees API to get a list of everything in our installation and then download all of the various appsettings files. – Tony Sullivan May 28 '20 at 14:11
  • @Lance Li-MSFT Could you please help to resolve this [issue](https://stackoverflow.com/questions/63407273/download-a-file-from-azure-devops-server-writes-wrong-data-to-the-file) . Your help is appreciated –  Aug 14 '20 at 09:17