【问题标题】:Is it possible to pass in a git repo tag to an ADO build pipeline as a variable?是否可以将 git repo 标记作为变量传递给 ADO 构建管道?
【发布时间】:2019-05-25 06:02:56
【问题描述】:

是否可以传入与 Azure DevOps 构建管道中的构建关联的 git 标记?

我们的标签包含正在构建和发布的软件版本,我想将版本传递给构建过程,以便它可以包含在正在构建的代码中。

我知道 Build.BuildNumberBuild.SourceBranch 之类的东西有预定义的变量,但我希望能够定义获取与构建所基于的底层 git 存储库关联的 git 标记。

【问题讨论】:

  • 我相当肯定Build.SourceBranch 将包含标签,如果构建是从标签开始的

标签: git azure-devops continuous-integration azure-pipelines azure-pipelines-build-task


【解决方案1】:

如果你构建的版本是一个标签(而不是分支/提交),你可以在这两个变量中获取标签值:

Build.SourceBranch = refs/tags/test
Build.SourceBranchName = test

【讨论】:

    【解决方案2】:

    是的,这是可能的。您可以根据您的标签定义 CI 触发器。

    请参考以下 azure devops 文档页面: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers

    如您所见,您有不同的选项定义您的触发器来使用标签。请参考以下 YAML 定义:

    trigger:
      branches:
        include:
          refs/tags/{tagname}
        exclude:
          refs/tags/{othertagname}
    

    或者

    # specific branch build
    trigger:
      tags:
        include:
        - v2.*
        exclude:
        - v2.0
    

    【讨论】:

      猜你喜欢
      • 2013-06-26
      • 2017-08-22
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-11
      • 1970-01-01
      相关资源
      最近更新 更多