简体   繁体   中英

Copying a file from one linux machine to another using Jenkins

I am working on Jenkins for CICD stuff. I have two linux machines machine1 and machine2. I have installed Jenkins on machine1 and using JenkinsFile and groovy to copy a file from machine1 to machine2 using scp sh command, but it failing because it is prompting for credentials on running JenkinsFile on runtime which cannot be provided to it everytime. So is there any way to copy a file without prompting for credentials to machine2. Thanks in advance.

Jenkins has an existing mechanism to share files between different nodes. The stash command lets you put some items in a named stash (you can select files in an ant-style format) and then unstash them on a different node.

This should solve your issues with credentials.

You can see an example here.

You could use pub/private keys instead of a password. If you do not provide a passphrase while installing them it should work without prompting for credentials.

Have a look at any of the following which explain in simple steps what commands to run to set up passwordless secure shell access:

http://www.phcomp.co.uk/Tutorials/Unix-And-Linux/ssh-passwordless-login.html

http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM