我已经读过这个和这个并且这个答案但是他们没有帮助我.我正在为Jenkins使用Windows机器
我的工作区只有以下文件
C:\ Jenkins\workspace\Copy_file\DevOps\resource\file1.txt C:\ Jenkins\workspace\Copy_file\DevOps\resource\file2.txt
我想在ssh上只发布file1.txt
我将插件添加到Publish Over SSH:
Source files DevOps\resource\file1.txt Remove prefix DevOps\resource Remote directory /tmp/
但是我在结果中看到:
C:\Jenkins\workspace\Copy_file\DevOps\resource\file1.txt SSH: Connecting from host [hhhhh] SSH: Connecting with configuration [Redhat1] ... SSH: Creating session: username [hhhh], hostname [iiiiii], port [22] SSH: Connecting session ... SSH: Connected SSH: Opening SFTP channel ... SSH: SFTP channel open SSH: Connecting SFTP channel ... SSH: Connected SSH: Remote root is not absolute, getting absolute directory from PWD SSH: Disconnecting configuration [Redhat1] ... SSH: Transferred 0 file(s) Build step 'Send files or execute commands over SSH' changed build result to SUCCESS Finished: SUCCESS
为什么发送0个文件?
如何将路径设为绝对路径,以便将其置于/ tmp /而不是/ home/user/tmp中?
更新
我有同样的问题,我在这篇文章中找到了解决方案.
特别是我发生的事情是,我们在插件配置中使用的用户无法访问"根路径"("/"),这导致连接默认位于"/ home/usery /"中.
确保您使用的用户可以访问绝对路径"/ tmp /",因为当我尝试使用相同的配置时,此用户创建了此路径(/ home/usery/tmp而不是/ tmp/path) ):
SSH:远程root不是绝对的,从PWD获取绝对目录SSH:cd [/ home/usery] SSH:OK SSH:mkdir [tmp] SSH:OK SSH:cd [tmp] SSH:OK SSH:put [myjar.jar ]
也许您的用户没有权限创建新目录.
尝试使用用户的"home"路径,例如,尝试创建路径"/ home/usery/localdir/anotherDir",然后将"Remote directory"的配置更改为"localdir/anotherDir".
最后,我们在Windows机器上安装了Jenkins,稍后我们将它移到Linux机器上,你必须小心路径分隔符"\"和"/",记住这一点:
源文件和删除前缀
我希望我的评论可以帮到你.