如何在 TFS 2015 的脚本中访问构建的自定义变量? [英] How to access a build's custom variable in script in TFS 2015?
问题描述
在 Team Foundation Server 2015 的构建定义中,我使用在变量"选项卡上定义的自定义变量.有什么方法可以在 PowerShell 构建步骤中访问它们,例如可以访问预定义的变量,例如$env:BUILD_DEFINITIONNAME"?谢谢
In Team Foundation Server 2015 in build definition I use my custom variables defined on Variables tab. Is there any way to access them in PowerShell build step like predefined variables can be accessed e.g. "$env:BUILD_DEFINITIONNAME"? Thank you
推荐答案
[disclaimer: I work on the new build system]
[disclaimer: I work on the new build system]
我经常建议人们使用 cmdline 任务或 cmd 脚本来打印变量(windows 上的调用集,*nix 上的 env).有文档等......但实际运行它会显示真正可用的内容.
I often advise folks to use the cmdline task or a cmd script to print out the variables (call set on windows, env on *nix). There's docs etc... but actually running it will show exactly what is really available.
使用工具 = cmd 和参数 =/k 设置添加 cmdline 任务(在实用程序中)
Add cmdline task (in utility) with tool = cmd and arguments = /k set
定义变量选项卡上的变量应可用作大写的环境变量
Variables on the definitions variable tab should be available as environment variables upper cased
所以:
my variable
可作为环境变量使用
MY VARIABLE
当前存在一个错误,它应该是每个规范 MY_VARIABLE.在 xplat 代理/shell 脚本上,它是 MY_VARIABLE
There is a current bug, it should be per spec MY_VARIABLE. On the xplat agent/shell script it's MY_VARIABLE
这使得它可以被 cmd、powershell、shell 等...脚本访问.
This makes it accessible to cmd, powershell, shell etc... scripts.
这篇关于如何在 TFS 2015 的脚本中访问构建的自定义变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!