简体   繁体   中英

How to trigger azure yml pipeline on tagging master branch only

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

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM