带有$(GitVersion.NuGetVersion)的标签源使用变量名创建标签,而不是值 [英] Label Sources with $(GitVersion.NuGetVersion) creates Tag with variable name, not value

查看:250
本文介绍了带有$(GitVersion.NuGetVersion)的标签源使用变量名创建标签,而不是值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在成功构建之后,将标签格式配置为 $(GitVersion.NuGetVersion),结果标记设置为 $(GitVersion。 NuGetVersion)不是该变量的实际扩展值。

在构建输出日志中,有两个部分/计划:构建和最终构建。

据推测,一旦构建代理移动到第二部分/计划,所有可变上下文/状态都将丢失。



如果GitVersion变量的上下文在Finalize Build部分中丢失,那么我应该如何标记源代码和生成的GitVersion?



https://github.com/Microsoft/vsts-agent / issue / 716

解决方案

实现我想要的结果的具体步骤:


  1. 设置VSTS Project / Repository / Build pre-reqs:

    https://www.visualstudio.com/en-us/docs/build/scripts/git -commands#enable-scripts-to-run-git-commands

  2. Git Docs用于标记(完整性):

    https://git-scm.com/book/en/v2/Git-Basics-Tagging

我补充道2命令行任务(批处理任务将是一个更好的主意)与工具: git


  1. 参数: 标记-a $(GitVersion_NuGetVersion)-m通过构建自动标记v $(GitVersion_NuGetVersion) .BuildId))

  2. 参数: push origin $(Build.BuildNumber)


After a successful build, having configured the Label Format as $(GitVersion.NuGetVersion), the resulting tag is set to $(GitVersion.NuGetVersion) not the actual expanded value of that variable.

In the build output logging, there are 2 sections/plans: Build, and Finalize Build.

Presumably, all the variable context/state is being lost once the build agent moves to the second section/plan.

How am I supposed to tag the source with the resulting GitVersion if the context of the GitVersion variables are lost during the Finalize Build section?

https://github.com/Microsoft/vsts-agent/issues/716

解决方案

Specific steps to achieve my desired result:

  1. Setup VSTS Project/Repository/Build pre-reqs:
    https://www.visualstudio.com/en-us/docs/build/scripts/git-commands#enable-scripts-to-run-git-commands
  2. Git Docs for tagging (for completeness):
    https://git-scm.com/book/en/v2/Git-Basics-Tagging

I added 2 Command Line Tasks (a Batch Task would be a better idea) with Tool: git:

  1. Arguments: tag -a $(GitVersion_NuGetVersion) -m "Auto-Tagged v$(GitVersion_NuGetVersion) by Build ($(Build.BuildId))"
  2. Arguments: push origin $(Build.BuildNumber)

这篇关于带有$(GitVersion.NuGetVersion)的标签源使用变量名创建标签,而不是值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆