1

Jenkins is running on windows machine and I am trying to copy files from windows to unix as a build step.

SSH sever details has been configured in the global configuration and connected successfully.

kindly share the Exec command to copy files from windows to unix

sampath
  • 185
  • 4
  • 6
  • 14
  • Can you clarify, is your unix machine a jenkins slave? In that case you can use the plugin https://wiki.jenkins-ci.org/display/JENKINS/Copy+To+Slave+Plugin If its just some random unix server, to push stuff via ssh to it, the unix machine needs a ssh server running. Also see http://stackoverflow.com/questions/21259811/how-to-copy-file-from-ssh-remote-host-to-jenkins-server – Dominik Gebhart Mar 22 '16 at 13:33

3 Answers3

1

You need some kind of ssh client on your windows. I suggest Winscp, which is simple, easy and fast. Winscp is a GUI application but as you want to run something from Jenkins you need to have a command line tool. Good news is that you can run Winscp in command line. Then the following steps should answer your question:

  1. Install Winscp on the Windows machine.

  2. Add your Winscp installation path (sth like C:\Program Files (x86)\WinSCP) to your system environment path variable

  3. Now you should be able to run winscp command in windows command prompt
  4. The command below will copy the file, you should read winscp manual for more details:

    winscp root:password@UNIX_MACHINE_IP /command "put c:/PATH_TO_FILE_ON_WINDOWS /home/PATH_TO_TARGET_ON_UNIX"

Ehsan Enayati
  • 299
  • 2
  • 16
1

There is a Jenkins plugin that might fit your needs:

https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin

It uses Java SSH library so no need to install another SSH client.

jil
  • 2,601
  • 12
  • 14
0

To copy files using PuTTY or any unix shell powered with SSH from windows, run this command.

scp /path/to/file.ext user@m192.168.0.100:/Destiny/path

To run commands in your remote computer just connect to it with:

ssh user@192.168.0.100

Customize the user, the IP and authenticate with the properly password.

Stiakov
  • 81
  • 1
  • 4