How to get Git Tag in Azure Pipelines

前端 未结 8 1092
青春惊慌失措
青春惊慌失措 2021-02-07 07:28

In Azure Pipelines, I have enabled git tags to trigger pipelines like so:

trigger:
  branches:
    include:
    - \'*\'
  tags:
    include:
    - \'*\'
<         


        
8条回答
  •  独厮守ぢ
    2021-02-07 08:20

    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.

提交回复
热议问题