Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

transferring 0 files using publish over SSH plugin in Jenkins

Tags:

ssh

jenkins

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

enter image description here

like image 360
Dejell Avatar asked Nov 20 '14 23:11

Dejell


People also ask

What does the publish over ssh Jenkins plugin do?

This plugin includes a builder which enables the use of the publisher during the build process. This means that you can send newly created packages to a remote server and install them, start and stop services that the build may depend on and many other use cases.

Which plugin allows to publish build artifacts via ssh?

sshPublisher : Send build artifacts over SSH. Send files or execute commands over SSH. Select to publish from the Jenkins master. The default is to publish from the server that holds the files to transfer (workspace on the agent, or artifacts directory on the master).


3 Answers

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.

like image 149
CamiGrunge Avatar answered Oct 08 '22 03:10

CamiGrunge


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 "/"

like image 26
roo2 Avatar answered Oct 08 '22 03:10

roo2


I have been researching about this plugin, but I can´t find the reason why doesn´t work.

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: Example 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: Example job 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!

like image 21
ajnavarro Avatar answered Oct 08 '22 05:10

ajnavarro