Getting the complete list of Repository names and details in Azure DevOps Project and Publishing as a CSV file using ADO Pipeline

 Author: Akhil M Anil || DevOps Engineer

Getting the complete list of Repository names in Azure DevOps Project using REST Api and Publishing as a CSV file

Representational State Transfer (REST) APIs are service endpoints that support sets of HTTP operations (methods), which provide create, retrieve, update, or delete access to the service's resources.

This article covers creating a REST API call pipeline in Azure DevOps to access the Repos and retrieve the list of all Repositories created and publish the list as a csv file.


Full code can be found in GitHub: Azure-DevOps/Repos-List

Nb: For authenticating to ADO, we are using PAT token. Ref: Use personal access tokens - Azure DevOps | Microsoft Learn 

Steps:

  • Push the developed pipeline (azure-pipelines-repos.yml) code and python (repos.py) code to Azure Repos.
    • If you have an existing PAT token use the PAT and make sure the PAT token has access to list the Repository list, if not create a PAT token and use the PAT token.
    • Create a Variable Group for storing PAT token as secret

    • We are using Repositories - List - REST API to fetch the repository list using python. For that we need to authorize to access the resources in ADO by using PAT token.
    • The above code can be used to authorize and access the resources/services in ADO
  • Create an ADO pipeline using the azure-pipelines-repos.yml. 
    • Navigate to 'Pipelines' in Azure DevOps. Select 'Create Pipeline' or 'New Pipeline' to create a new pipeline.





  • Run the pipeline
    • Pipeline will authenticate with ADO using PAT token and fetch the API results and publish as an artifact.



Perfect! We got the list of Repositories in our ADO project!



Comments

Popular posts from this blog

Install Java silently using powershell in Azure Windows VM

Configure an Azure DevOps self-hosted Windows agent in Docker

List of Repositories - Authorize Rest API calls using Job Access Token