Search code examples
azure-devopsazure-pipelinesazure-sdk-.netazure-rest-api

Get file names in a commit in azure devops using rest api c#


I am trying to get the list of files that changed in a commit in AzureDevOps. Is there an api to get this information ?

I am using this but not able to get the information for files.

https://learn.microsoft.com/en-us/rest/api/azure/devops/build/attachments/get?view=azure-devops-rest-6.0

var attachment = buildClient.GetAttachmentsAsync(projectName, buildRunId, commititem.Type).Result;

The above code returns empty value.


Solution

  • Is there an api to get this information ?

    Yes. You can get the file names in a commit with this API: Commits - Get Changes

    GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/changes?api-version=6.0
    

    For .net sdk, you can refer to this class: GitCommitChanges Class