I have a build pipeline that is triggered by CI on check-ins to master and want to add a PR trigger. The build includes publishing steps that I'd like to not occur when the build is triggered by a PR. Is there a way to use the same build pipeline but set a variable based on how the build is triggered?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Using variables['Build.Reason'] as a condition for the publishing steps should do the trick, e.g. in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')) for CI and in(variables['Build.Reason'], 'PullRequest')) for PR triggered builds.
Thanks, that worked!
@mkajerski Thank you for supplying that information. @erinha I'm glad that worked for you. If you wanted to make an update to our documentation, you could submit a PR against this article here, and maybe add it down in the QA section at the bottom? Or if you want to file a new issue on this topic, I can add it for you if you supply me a snippet of what you did?
Most helpful comment
Using variables['Build.Reason'] as a condition for the publishing steps should do the trick, e.g. in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')) for CI and in(variables['Build.Reason'], 'PullRequest')) for PR triggered builds.
See https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml