Label Sources with $(GitVersion.NuGetVersion) 创建带有变量名的标签,而不是值
Label Sources with $(GitVersion.NuGetVersion) creates Tag with variable name, not value
成功构建后,将标签格式配置为 $(GitVersion.NuGetVersion)
,生成的标签设置为 $(GitVersion.NuGetVersion)
而不是该变量的实际扩展值。
在构建输出日志记录中,有 2 个 sections/plans:Build 和 Finalize Build。
据推测,一旦构建代理移动到第二个 section/plan,所有变量 context/state 都将丢失。
如果 GitVersion 变量的上下文在 Finalize Build 部分丢失,我应该如何用生成的 GitVersion 标记源?
我在 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.
实现我想要的结果的具体步骤:
- 设置 VSTS Project/Repository/Build 先决条件:
https://www.visualstudio.com/en-us/docs/build/scripts/git-commands#enable-scripts-to-run-git-commands
- Git 标记文档(为了完整性):
https://git-scm.com/book/en/v2/Git-Basics-Tagging
我使用 Tool: git
:
添加了 2 个命令行任务(批处理任务会更好)
- 参数:
tag -a $(GitVersion_NuGetVersion) -m "Auto-Tagged v$(GitVersion_NuGetVersion) by Build ($(Build.BuildId))"
- 参数:
push origin $(Build.BuildNumber)
成功构建后,将标签格式配置为 $(GitVersion.NuGetVersion)
,生成的标签设置为 $(GitVersion.NuGetVersion)
而不是该变量的实际扩展值。
在构建输出日志记录中,有 2 个 sections/plans:Build 和 Finalize Build。
据推测,一旦构建代理移动到第二个 section/plan,所有变量 context/state 都将丢失。
如果 GitVersion 变量的上下文在 Finalize Build 部分丢失,我应该如何用生成的 GitVersion 标记源?
我在 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.
实现我想要的结果的具体步骤:
- 设置 VSTS Project/Repository/Build 先决条件:
https://www.visualstudio.com/en-us/docs/build/scripts/git-commands#enable-scripts-to-run-git-commands - Git 标记文档(为了完整性):
https://git-scm.com/book/en/v2/Git-Basics-Tagging
我使用 Tool: git
:
- 参数:
tag -a $(GitVersion_NuGetVersion) -m "Auto-Tagged v$(GitVersion_NuGetVersion) by Build ($(Build.BuildId))"
- 参数:
push origin $(Build.BuildNumber)