How to pass build parameters and other information to powershell script in TFS2013 build?

。_饼干妹妹 提交于 2019-12-03 06:01:21

问题


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?

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.

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?


回答1:


Figured it out.

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


来源:https://stackoverflow.com/questions/22293671/how-to-pass-build-parameters-and-other-information-to-powershell-script-in-tfs20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!