Reputation: 1132
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://learn.microsoft.com/en-us/azure/devops/repos/git/pull-request-status?view=azure-devops
Upvotes: 3
Views: 1190
Reputation: 2560
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.
Upvotes: 1
Reputation: 1327
on dev.azure.com portal, if you go to pipelines and last run click on the link, and the highlight here which will take you to the GitHub with changes in the pull request
Upvotes: 0