问题描述
我使用默认的编译模板,TFS 2013,我怎么能(下构建例如,变更号码,建立目录,源文件路径,TFS地址,代理信息......)访问构建参数从PowerShell脚本?
I am using default build template with TFS 2013, how i can access build parameters (for example, changeset number under build, build directory, source paths, tfs address, agent information...) from powershell script?
例的情况:我想重写的pre-构建脚本所有装配信息版本信息,其中的版本号最后一部分是变更电话号码,我可以可能得到变更,里面的脚本命令tf.exe但我ISN只有T,我想在生成过程中从生成代理知道的事情。
Example situation: I want to rewrite all assembly info version informations on Pre-Build script where last part of version number is changeset number, i can probably get changeset with tf.exe commands inside of script but i isn't only thing which i want to know from build agent during build.
我曾尝试运行获取变量脚本,并将其写入建立,但我还没有找到脚本内的任何特殊变量。
I have tried run Get-Variable in script and write it to build but i haven't find any special variables inside of script.
是不是我错过了或者是它使默认的编译模板根本不执行过程中传递给PowerShell运行时的变量?
Is there something i have missed or is it so that default build template simply does not pass any variables to powershell runtime during execution?
推荐答案
想通了。
变量自动写入作为环境变量,DIR ENV:向我表明TFS自动创建以下变量:
Variables are automatically written as environment variables, dir env: showed me that tfs automatically create following variables:
TF_BUILD True
TF_BUILD_BINARIESDIRECTORY C:\WP0\101\bin
TF_BUILD_BUILDDEFINITIONNAME TfsBuildTest2
TF_BUILD_BUILDDIRECTORY C:\WP0\101
TF_BUILD_BUILDNUMBER TfsBuildTest2_20140310.3
TF_BUILD_BUILDREASON Manual
TF_BUILD_BUILDURI vstfs:///Build/Build/6521
TF_BUILD_DROPLOCATION
TF_BUILD_SOURCEGETVERSION C22404
TF_BUILD_SOURCESDIRECTORY C:\WP0\101\src
TF_BUILD_TESTRESULTSDIRECTORY C:\WP0\101\tst
TFS_REG_CRED Build
这篇关于如何通过建立TFS2013参数等信息,PowerShell脚本建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!