1
votes

I have consulted this document below

https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml

I used this trigger to control condition branch master and git tag.

trigger:
branches:
include:
- master
- refs/tags/development

When i push source code to branch "master" AND with git tag "development", the pipeline will be built. But i push to branch "master" OR Pushed git tag is "development". The pipeline also will be built. How can i control "AND" condition for branch and git tag.

2
No , i can't control "AND" condition for branch and git tagCuong Doan Nhu Vu

2 Answers

0
votes

I dont think you can have conditions in the triggers, you can only list what it will trigger on, then you can put conditions on the tasks, or do some check, say branch is not master then fail the step and fail the pipeline.

but I dont think this makes sense, as a tag is a pointer to commit, so it doesn't make a lot of sense. this commit can be on any branch

https://stackoverflow.com/a/27154277/6067741

0
votes

Tag is a Reference point of a branch. So doesn't make sense to have an OR condition.

In yaml you can specifically define the tags that you want to include and exclude. Also, the branches you want to include and exclude.

This will help anyone looking at the code to understand the different better.

trigger:
  branches:
    include:
    - master
    - develop
  tags:
    include:
    - v1
    - v2

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'