Tracy Theron
Tracy Theron

Reputation: 343

SCP didn't work in Jenkins

When I use the following codes in terminal, it works well.

#!/usr/bin/expect -f
spawn scp /Users/Shared/Jenkins/workspace/testslave/XXXXXX [email protected]:/tmp/XXXX
expect "*assword:"
send "password\r"
interact

but when I copy the content to the Jenkins,the Jenkins didn't copy the file to the destination,and with no error.

Upvotes: 1

Views: 2889

Answers (1)

Adrián Deccico
Adrián Deccico

Reputation: 4995

A cleaner approach is to generate a public/private key with no pass-phrase and to use it as an authentication method.

The steps are:

  1. Generate the key by executing ssh-keygen
  2. Copy the public key (usually id_rsa.pub) to the .ssh folder of the user in the destination host. In your case it seems to be /Users/Shared/Jenkins/.ssh
  3. Execute: scp -i id_rsa /Users/Shared/Jenkins/workspace/testslave/XXXXXX [email protected]:/tmp/XXXX

Upvotes: 1

Related Questions