Azure-devops-docs: How to reuse tasks between CI triggers and PR triggers?

Created on 21 Aug 2019  Â·  3Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

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?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-cictech devopprod product-question

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

All 3 comments

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

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?

Was this page helpful?
0 / 5 - 0 ratings