1
votes

for pipelines that are triggered to validate a pull request, is it possible to access the PR information from the pipeline? such as what is changed

I have a large repository of scripts and configs and it doesn't make sense to check all of them if only a few files are touched in a PR

I have looked at this but it doesn't have much information https://docs.microsoft.com/en-us/azure/devops/repos/git/pull-request-status?view=azure-devops

2

2 Answers

0
votes

on dev.azure.com portal, if you go to pipelines and last run click on the link, first page and the highlight here PR link which will take you to the GitHub with changes in the pull request

0
votes

From the pipeline that is configured as the part of the build Policy for your PR, you could use the $(Build.SourceVersion) variable and call the Rest API to find out what was changed in a Commit. Or maybe just do it with a git command git diff COMMIT

And from there, based what was changed and what you want to test, set environment variables, that you then use in conditions to only run certain Stages\Jobs\Steps in your pipeline. Depending on what you need to validate or test...

Another easier route to consider is creating separate validation pipelines for the different parts of the Scripts repository. Then for your Branch Policy that triggers the PR, configure path filters for your each of your Build policies, so that a pipeline is only run if a change is made to files in a given path.

enter image description here