0
votes

Regarding azure yml pipeline trigger

How to achieve below requirements I want to trigger my azure yml pipeline

  • Should trigger pipeline on master branch if PR is merged to master branch
  • Should trigger pipeline on master branch if git tag is added on master branch.
  • Should not trigger pipeline if git tag is added on non-master branches (like develop, features branches)
  • Should trigger pipeline on non-master branches if PR is merged or commit happens on these branches

How to handle this any idea, I have below trigger set as of now?

trigger:
  branches:
    include:
    - develop
    - master
    - features/*
  paths:
    exclude:
    - README.md
    - azure-pipelines.yml
  tags:
    include:
    - refs/tags/*-RELEASE
1

1 Answers

0
votes

In the Azure DevOps Service, the yaml build just trigger current branch, such as the .yml file in the dev branch, and add Push trigger trigger - master, then push code in the master branch, it will not trigger the build.

As a workaround, we need to update the .yml content in the different branch.

For example, If we create YAML build in the master branch, it will create azure-pipelines.yml file in the master branch.

  • Should trigger pipeline on master branch if PR is merged to master branch
  • Should trigger pipeline on master branch if git tag is added on master branch.

We can do this by adding the following push triggers

trigger:
  batch: true
  branches:
    include:
    - master
  tags:
    include:
    - refs/tags/*-RELEASE
  • Should not trigger pipeline if git tag is added on non-master branches (like develop, features branches)
  • Should trigger pipeline on non-master branches if PR is merged or commit happens on these branches

Then create branch develop and features, it also contain the file azure-pipelines.yml, edit the file content.

trigger:
  batch: true
  branches:
    include:
    - develop #in the develop enter develop, in the feature branch, we need to update it to feature.
  tags:
    exclude:
    - refs/tags/*-RELEASE

Update1

enter image description here