从文件中读取 TFS 构建变量
Read TFS build variables from file
是否可以从 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
您可以使用 Batch 脚本任务或 PowerShell 脚本在 windows 代理上 运行 脚本任务。您只需要阅读源代码管理中的特定文件,将其下载到构建代理的工作区中。然后读取文件,使用powershell的方式供大家参考:
是否可以从 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
您可以使用 Batch 脚本任务或 PowerShell 脚本在 windows 代理上 运行 脚本任务。您只需要阅读源代码管理中的特定文件,将其下载到构建代理的工作区中。然后读取文件,使用powershell的方式供大家参考: