twiz
twiz

Reputation: 10548

Azure DevOps Pipeline run only on specific tag

I have an Azure DevOps Pipeline that I want to only run when a specific tag is pushed to the repo, but for some reason it always runs on every commit.

My azure-pipelines.yml has the trigger setup like this:

trigger:
  tags:
    include:
      - mytag.*

I also tried excluding all branches:

trigger:
  branches:
    exclude:
      - "*"
  tags:
    include:
      - mytag.*

It seems like it makes no difference what the trigger is set as, it just always runs on every commit.

How do I make it run only when I push a tag?

Upvotes: 2

Views: 6914

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40543

I tried what you wrote and it seems to be working:

trigger:
  branches:
    exclude:
      - '*'
  tags:
    include:
    - v2.*
    exclude:
    - v2.0

pr:
  branches:
    include:
      - refs/tags/v2.*
    exclude:
      - 'refs/tags/v2.0'
      - '*'

So for this configuration when I make a commit, the build is not triggered. Only when I push a tag the build runs. It picks up last commit, but this this is clearly triggered by tag.

enter image description here

Here for instance you have another build which was triggered by Test commit

enter image description here

Upvotes: 6

Related Questions