Search code examples
gitbuildazure-devopsrelease-managementpull-request

Can I use an Azure Dev Ops build definition both for a Release Management pipeline and a pull request but with the latter not triggering the pipeline


In short; we want to use a build definition to both generate artifacts for Release Management and checking Pull Requests, but not allow the latter to trigger a new release.

We have CI build definition on our Git Repo feeding artifacts into a Release Management Pipeline. Like many teams we also have Pull Requests set up to protect our git master. We'd like to reuse our CI build to validate Pull Requests before they are merged in but doing so automatically triggers our release pipeline (bypassing the merge to master).

We've been working round this so far by duplicating builds but that feels clunky. Looking through the documentation there isn't an obvious way to filter a Release Trigger, or skip the publishing step in the build. I feel there must be away of preventing the trigger without duplicating the build but I can't see it!


Solution

  • Azure Dev Ops now has a way of achieving this behaviour. You can modify the Continuous Deployment trigger for a Release definition. The two applicable options are:

    • Disable the (handily titled) Pull Request trigger
    • Add a branch filter i.e. include only master

    Screenshot of Continuous deployment trigger setup dialog

    Note another answer suggested making the artifact upload conditional, however we still needed the artifact for other reasons.