TFS 2015/2017 中 PowerShell 的构建放置位置环境变量名称是什么

What is the Build Drop Location environment variable name for PowerShell in TFS 2015/2017

在以前的TFS版本中(2015年之前),有一个PowerShell的构建环境变量叫做:TF_BUILD_DROPLOCATION,它给出了drop的位置: https://msdn.microsoft.com/library/hh850448%28v=vs.120%29.aspx.

我在 TFS 2017 中找不到等效变量。 获得它的最佳做法是什么?

您可以使用以下命令列出所有环境变量:

get-childitem ENV:\

我假设您可以创建一个简单的构建作业来执行它,然后查看控制台输出以确定您需要的环境变量的名称。

有了构建代理任务,接管事情就不同了。为了查看各种构建环境变量,我所做的是制作一个包含以下内容的简单批处理文件:

SET C:\temp\EnvVars.txt

这将生成可用内容的快速列表。

这是我在 TFS 2017 构建代理中看到的内容:

agent.jobstatus=Succeeded 
AGENT_BUILDDIRECTORY=C:\Agent\_work
AGENT_HOMEDIRECTORY=C:\Agent 
AGENT_ID=2 AGENT_JOBNAME=Build
AGENT_JOBSTATUS=Succeeded
AGENT_MACHINENAME=BUILDMACHINE
AGENT_NAME=BUILDMACHINE
AGENT_OS=Windows_NT
AGENT_ROOTDIRECTORY=C:\Agent\_work
AGENT_SERVEROMDIRECTORY=C:\Agent\externals\vstsom
AGENT_TEMPDIRECTORY=C:\Agent\_work\_temp
AGENT_TOOLSDIRECTORY=C:\Agent\_work\_tool
AGENT_VERSION=2.122.1
AGENT_WORKFOLDER=C:\Agent\_work
BUILD_ARTIFACTSTAGINGDIRECTORY=C:\Agent\_work\a
BUILD_BINARIESDIRECTORY=C:\Agent\_work\b
BUILD_BUILDID=2036
BUILD_BUILDNUMBER=Database Build_20190708.2
BUILD_BUILDURI=vstfs:///Build/Build/2036
BUILD_CONTAINERID=2281
BUILD_DEFINITIONNAME=Database Build
BUILD_DEFINITIONVERSION=17
BUILD_QUEUEDBY=Smith, John
BUILD_QUEUEDBYID=8c588342-b87a-40cb-9b8c-a0ed10b57a3f
BUILD_REASON=Manual
BUILD_REPOSITORY_CLEAN=false
BUILD_REPOSITORY_GIT_SUBMODULECHECKOUT=False
BUILD_REPOSITORY_ID=$/
BUILD_REPOSITORY_LOCALPATH=C:\Agent\_work\s
BUILD_REPOSITORY_NAME=Collection
BUILD_REPOSITORY_PROVIDER=TfsVersionControl
BUILD_REPOSITORY_TFVC_WORKSPACE=ws_2_2
BUILD_REPOSITORY_URI=http://TFSSERVER:8080/tfs/Project/
BUILD_REQUESTEDFOR=Smith, John
BUILD_REQUESTEDFOREMAIL=John.Smith@Mailinator.com
BUILD_REQUESTEDFORID=7a588222-b66a-40ee-9b2a-a0ba10b12a3f
BUILD_SOURCEBRANCH=$/Collection/Project/Code
BUILD_SOURCEBRANCHNAME=Code
BUILD_SOURCESDIRECTORY=C:\Agent\_work\s
BUILD_SOURCEVERSION=9811
BUILD_SOURCEVERSIONAUTHOR=Smith, John
BUILD_SOURCEVERSIONMESSAGE=Added missing permission
BUILD_STAGINGDIRECTORY=C:\Agent\_work\a