transferring 0 files using publish over SSH plugin in Jenkins

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

I already read this and this and this answers but non of them helped me. I am using Windows machine for Jenkins

My workspace has only the following files

C:\Jenkins\workspace\Copy_file\DevOps\resource\file1.txt C:\Jenkins\workspace\Copy_file\DevOps\resource\file2.txt

I would like to publish over ssh only file1.txt

I added the plugin to Publish Over SSH:

Source files  DevOps\resource\file1.txt Remove prefix DevOps\resource Remote directory /tmp/ 

However I see in the result:

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 
  1. Why is it sending 0 files?
  2. How can I make the path absolute so it will put it in /tmp/ and not in /home/user/tmp?

UPDATED

回答1:

I had the same problem and I ended in this post looking for the solution.

  • Specifically what happened to me, is that the user we use in the plugin configuration did not have access to the "root path" ("/"), which cause the connection to be default located in "/home/usery/".

  • Make sure the user that you are using have access to the absolute path "/tmp/" because when I tried with the same configuration that you have this user created this path (/home/usery/tmp and not in the /tmp/ path):

SSH: Remote root is not absolute, getting absolute directory from PWD SSH: cd [/home/usery] SSH: OK SSH: mkdir [tmp] SSH: OK SSH: cd [tmp] SSH: OK SSH: put [myjar.jar]

Maybe you user does not have permissions to create a new directory.

  • Try to use the "home" path of the user, for example, try to create a path "/home/usery/localdir/anotherDir", then change the configuration of "Remote directory" to "localdir/anotherDir".

  • Finally, we installed Jenkins on a Windows machine, later we move it to a Linux machine, you have to be careful with the path separator "\" and "/", keep this in mind setting up:

    source files and remove prefix

I hope my comments help you.



回答2:

The Q.A. team in my company uses this plugin and it works ok.

By try to answering your question I will try to explain the configuration about this new plugin:

  • Into global configuration:

    • hostname: is-bvt-rh-01.XXXXX.com
    • port: 22
    • Root Repository Path: / (To allow put files in /tmp/ instead of /home/user/tmp. Root repository path must exist before you can reference it and should be accessible by user who do publish of files.)
    • User Name: bvtuser
    • Password: [YOUR_SSH_PASSWORD]
  • Into your job-specific configuration:

    • SCP site: is-bvt-rh-01.XXXXX.com
    • Source: DevOps\resource\file1.txt (Path is constructed from workspace root.)
    • Destination: tmp/

Hope it helps!



回答3:

I ended up using

  1. Execute Shell plugin to transfer the file over.

  2. Then use Publish over SSH plugin to execute mysql command to my RDS instance using the SQL script contained in the uploaded file.



回答4:

After looking at the plugin source code, it appears that it defaults to using a relative path if no "Remote Directory" is set in your ssh server configuration.

Go to Manage Jenkins/Confgiure System and under the plugin settings for publish over ssh, set Remote Directory to "/"



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!