sampath
sampath

Reputation: 205

send files or execute commands over ssh

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

Upvotes: 1

Views: 11540

Answers (3)

Stiakov
Stiakov

Reputation: 89

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

scp /path/to/file.ext [email protected]:/Destiny/path

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

ssh [email protected]

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

Upvotes: 0

jil
jil

Reputation: 2691

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.

Upvotes: 1

Ehsan Enayati
Ehsan Enayati

Reputation: 309

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"

Upvotes: 1

Related Questions