Ric*_*ier 9 deployment msbuild build-automation sftp
有谁知道msbuild的SFTP任务?我们希望将我们的部署自动化到生产中,但出于安全考虑,我们不允许从开发/测试/构建环境到生产的SMB文件共享访问.
现在,开发人员通过SFTP连接使用FileZilla手动上传文件来部署代码.这非常容易出错,因此我们计划自动执行SFTP上传.虽然除了SFTP之外还有一些机制可以同样安全,但我很乐意使用它.
我正在考虑使用"exec"msbuild任务和命令行ftp客户端,如pscp.但如果有人已经建立了一个sftp任务,那当然会很棒.
谢谢,
理查德
可以安装WinSCP并只使用MsBuild Exec任务
在构建之后,我使用类似下面的内容将ISO文件上传到服务器.
winscp.exe sftp://root:password;@192.168.0.200:22/uploaddir/ "c:\myfile.iso"
Run Code Online (Sandbox Code Playgroud)
我通常会像Ryu一样完成并使用WinSCP,但我更进一步,使用WinSCP的脚本功能来映射更可定制的部署.
我在博客文章中详细说明了这一点,详细介绍了完整设置:
http://www.diaryofaninja.com/blog/2010/09/21/continuous-integration-tip-1-ndash-ftp-deployment
但它的基本要点是将脚本文件传递给WinSCP,如下所示:
<Target Name="AfterBuild">
<!-- Set the path to your FTP program (winscp) -->
<PropertyGroup>
<PathToWinSCP>"C:\Program Files (x86)\WinSCP\winscp.exe"</PathToWinSCP>
</PropertyGroup>
<!-- Get the date as a string for our log filename-->
<GetDate Format="yyyyMMdd">
<Output PropertyName="DateString" TaskParameter="Date"/>
</GetDate>
<!-- Convert the path to an absolute path -->
<ConvertToAbsolutePath Paths="$(OutputPath)">
<Output TaskParameter="AbsolutePaths" PropertyName="OutputPath"/>
</ConvertToAbsolutePath>
<!-- Fire WinSCP and give it your script files name
as well as passing it the parameter to this build -->
<Exec Command="$(PathToWinSCP) /script=$(OutputPath)Deployment\FtpDeployment.config /parameter $(OutputPath) /log=$(OutputPath)FtpLog-$(DateString).txt" />
</Target>
Run Code Online (Sandbox Code Playgroud)
我的脚本看起来像:
option batch abort
option confirm off
open ftp://myUsername:myPassword@ftp.myftpsite.com
put %1%\*
rm FtpDeployment.config
exit
Run Code Online (Sandbox Code Playgroud)