How to pass build parameters and other information

2019-03-10 11:29发布

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条回答
闹够了就滚
2楼-- · 2019-03-10 11:59

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
查看更多
登录 后发表回答