Search code examples
gitazure-devopsazure-devops-rest-api

Get changed files list for one Pull Request


I also need to require to list the list of files modified in particular pull request in Azure DevOps services.

I have checked some threads, like List changed files of a Pull Request using powershell or git, but it not given the solution. Most of the answers are for github, not azure devops.

So, I'm wondering if there is such a direct git command to fetch it, and if not, how can this be achieved using the corresponding Azure Devops REST API script? Please help.

Background:

I created a pipeline which is triggered by the PR (Build Validation) on the SIT branch:

enter image description here

The configuration of the pipeline is as follow:

enter image description here

The ModifiedFileTest is the my test branch name, which based on the SIT branch:

The output:

enter image description here


Solution

  • LeGEC's answer is correct.

    In Azure DevOps Pipeline, you need to set the remote source, then you can run git diff to get the changed files.

    Example:

    git remote add  origin1 RepoURL
    git remote update    
    git diff  origin1/test  origin1/master
    

    Then we can get the changed files.