tfs - 从文件中读取 TFS 构建变量

标签 tfs tfsbuild

是否可以从 git 源代码管理中读取文件并将值设置为 TFS 构建变量,以便我们可以在其他步骤中使用它们?

我们有一个包含版本信息和分支(VER_TYPE=3 是 DEV)的文件,我们用它来设置程序集版本和内部版本号

VER_MAJOR=2018 VER_MINOR=1 VER_TYPE=3

提前致谢!

最佳答案

可以从脚本定义或修改变量,使用 task.setvariable 日志命令。

Sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.

When issecret is set to true, the value of the variable will be saved as secret and masked out from log. Secret variables are not passed into tasks as environment variables and must be passed as inputs.

例子:

##vso[task.setvariable variable=testvar;]testvalue
##vso[task.setvariable variable=testvar;issecret=true;]testvalue

更多详情请引用Define and modify your variables in a script

您可以使用批处理 脚本任务或PowerShell 脚本任务在Windows 代理上运行脚本。您只需要阅读源代码管理中的特定文件,将其下载到构建代理的工作区中。然后读取文件,使用powershell的方式供大家引用:Read file line by line in PowerShell

关于tfs - 从文件中读取 TFS 构建变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48466294/

相关文章:

TFS '$(BuildLocation)' 宏指向实验室环境模板上的错误路径

tfs - 更改 TFS 构建质量到底有什么作用?

tfs - 仅在 checkin 特定文件夹和子文件时触发构建 - 持续集成 TFS

npm - TFS npm install 构建任务挂起?

visual-studio - 在分支之间合并 TFS 变更集而不是选择文件

c# - TFS 中的内部版本号格式

visual-studio - Windows 工作流设计器元数据编辑器(vs.net 2010)

visual-studio-2012 - 将 TF.exe 与 Team Foundation Service 一起使用?

tfs - 在 TFS 中合并提交

tfs - 可以从 Visual Studio Online 中删除已完成的迭代吗?