Label Sources with $(GitVersion.NuGetVersion) creates Tag with variable name, not value

佐手、 提交于 2019-12-04 11:16:03

I answered your question in the issue on GitHub:

I don't think there is anything we can do inside of the GitVersion task about this as long as VSTS doesn't provide an appropriate API. GitVersion currently just defines the variables using the ##vso[task.setvariable]value command. Variables are explicitely defined in the task context, and therefor available for subsequent tasks, but not outside of the context.

A special case is the build number for which a special command exists ##vso[build.updatebuildnumber]build number which we are using.

A workaround can be to add an additional task which adds the tag, which will work since the task will be in the same context and have therefore access to the variable.

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!