是否可以从 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/