How to get Git Tag in Azure Pipelines

前端 未结 8 1087
青春惊慌失措
青春惊慌失措 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:25

    The accepted answer using git tag -l v* didn't work for me as it didn't order the tags correctly, instead giving 1.1, 1.11, 1.12, 1.2, 1.3, etc.

    I found it better to do:

    $tags = git tag --sort=-creatordate
    $tag = $tags[0]
    

    This sorts the tags correctly for both annotated and unannotated tags, and so the first result is the most recent tag.

提交回复
热议问题