简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM