简体   繁体   English

TFS 以编程方式获取构建代理工作文件夹

[英]TFS get build agent working folder programmatically

Is there any way to programmatically retrieve the working folder of a build agent (through TFS REST API)?有没有办法以编程方式检索构建代理的工作文件夹(通过 TFS REST API)?

I'd like to clean this folder during the reboot of the build agent.我想在构建代理重新启动期间清理此文件夹。

There isn't the REST API to retrieve the working folder of a build agent.没有用于检索构建代理的工作文件夹的 REST API。

The working folder is defined when your deploy the build agent.工作文件夹是在部署构建代理时定义的。 Commonly it should be like this D:\VSOAgent_work (the location which you deployed the agent to).通常它应该像这样D:\VSOAgent_work (您将代理部署到的位置)。

To clean the folder during the reboot of the build agent, you just need to create a .cmd/.bat file to delete the _work directory, and copy it into the start up folder in Windows Explorer.要在构建代理重启期间清理该文件夹,您只需创建一个.cmd/.bat文件来删除_work目录,并将其复制到 Windows 资源管理器中的启动文件夹中。

Please note that you need to run the cmd/bat with administrator .请注意,您需要以管理员身份运行 cmd/bat

Delete command sample: (Just change the dir accordingly, the command will delete all the files and sub-folders, but not delete the directory _work)删除命令示例:(只需相应更改目录,该命令将删除所有文件和子文件夹,但不会删除目录 _work)

@ECHO OFF

Set dir=D:\VSOAgent\_work\

Echo Deleting all files from %dir%
del %dir%\* /F /Q

Echo Deleting all folders from %dir%
for /d %%p in (%dir%\*) Do rd /Q /S "%%p"
@echo Folder deleted.


exit

To find the Startup folder:要找到启动文件夹:

For your user account: Win + R run shell:startup对于您的用户帐户:Win + R run shell:startup
For all users Win + R run shell:common startup对于所有用户 Win + R run shell:common startup

For how to auto start Programs as Administrator, you can reference this article: http://www.thewindowsclub.com/autostart-programs-windows-10-make如何以管理员身份自动启动程序,可以参考这篇文章: http ://www.thewindowsclub.com/autostart-programs-windows-10-make

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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