Reputation: 14317
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
- Why is it sending 0 files?
- How can I make the path absolute so it will put it in /tmp/ and not in /home/user/tmp?
UPDATED
Upvotes: 10
Views: 17170
Reputation: 1665
The source file path will be relative to the Jenkins project workspace.
For example, if you create a job named rmr, and you have an archive file named file.zip then following is the path of the file:
/var/lib/jenkins/workspace/ormr/file.zip
(rmr is the project name)
... therefore you will need to provide the path relative to your project workspace as below
Source files: file.zip
Remove prefix:
Remote directory: //home//ec2-user//rmr//target
Exec command:
Note that the target path separators have been double escaped.
Upvotes: 0
Reputation: 6071
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 "/"
Upvotes: 4
Reputation: 11
I ended up using
Execute Shell plugin to transfer the file over.
Then use Publish over SSH plugin to execute mysql command to my RDS instance using the SQL script contained in the uploaded file.
Upvotes: 0
Reputation: 61
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.
Upvotes: 6
Reputation: 738
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:
Into your job-specific configuration:
Hope it helps!
Upvotes: 2