繁体   English   中英

在使用TeamCity通过SMB上传文件之前,如何从远程文件夹中删除所有内容

[英]How to delete all content from remote folder before uploading files through SMB with TeamCity

我正在Windows计算机上运行TeamCity服务器和代理。 在构建过程中,我的最后一步是通过SMB将bin / release文件上传到另一台服务器上的共享Windows文件夹中。

在上传新版本之前,我需要删除所有在远程服务器上归档的文件,但是找不到解决方法。

我在SMB上传运行程序中看不到任何此类选项。

是的,您是正确的,应该将其作为构建步骤下的一个步骤添加,我希望使用类似这样的powershell命令

robocopy \\%WebServer1%\%SourceFolder% \\%WebServer1%\%DestinationFolder% /E /PURGE /IS /COPY:DT /R:1 /W:2
RMDir /S "%WebServer1%\%SourceFolder%

Where, 
    /E - Copies sub directories
    /PURGE - Deletes destination files and directories that no longer exist in the source
    /COPY:DT - Specifies the file properties to be copied, in this case it copies Data and Timestamps
    /R:1 - Specifies the number of retries on failed copies, in this case it is 1
    /W:2 - Specifies the wait time between retries, in seconds, in this case it is 2 seconds
    /s - Includes subdirectories

自动复制成功后,RmDir将删除源目录。

如果您需要直接删除文件而不是先复制再删除,则可以使用Move

移动参考-https: //docs.microsoft.com/zh-cn/windows-server/administration/windows-commands/move

我个人更喜欢复制和删除

暂无
暂无

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

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