In Azure Pipelines, I have enabled git tags to trigger pipelines like so:
trigger:
branches:
include:
- \'*\'
tags:
include:
- \'*\'
<
The other answers here cover the first part of the question, so as Alex Kaszynski has already pointed out, you can use a YAML condition:
startsWith(variables['Build.SourceBranch'], 'refs/tags/')
Getting the tag name is now a bit easier than it was at the time the question was asked:
Build.SourceBranchName
This variable contains the last git ref path segment, so for example if the tag was refs/tags/1.0.2
, this variable will contain 1.0.2
: the tag name.
Full docs are now here.