ivan saron
ivan saron

Reputation: 107

how to exclude build all branches except master branch in Azure Pipelines?

Currently my pipeline always runs builds on other branches, My expectation is that my pipeline only need to run build of a single branch which is master branch only.

Trigger from my yml is simply like this

enter image description here How do I need to change the yml so that it can be achieved as expected?

Upvotes: 5

Views: 2732

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13514

If you want the YAML build pipeline can only be triggered form the master branch, you can try with the things:

  1. Only keep the YAML file on the master branch. And make sure the branches filter on the trigger only include master.

    trigger:
      branches:
        include:
        - master
    
  2. If you cannot only keep the YAML file on the master branch, make sure the YAML file on each branch has the same branches filter as above.

  3. Set the trigger from the settings page and only include the master branch. With this way, the triggers set in the YAML files will be overridden by that on the settings page.

    enter image description here

Upvotes: 6

Related Questions