I've setup some global credentials in jenkins, username password type.
I've now got to scp a file over to a target server inside my pipeline.
For arguments sake, lets say my password variable is secretpassword.
Does anyone know how to get the password to work properly with sshpass?
Here's the gist of what I'm trying to do
sh '''
sshpass -p'${PASSWORD}' scp ${WORKSPACE}/target/citest-1.0-SNAPSHOT.jar root@target_service:/
'''
Whatever I try I can't seem to get the syntax right for passing the password to sshpass
If I do the following, it works fine
sh '''
sshpass -p 'secretpassword' scp ${WORKSPACE}/target/citest-1.0-SNAPSHOT.jar root@target_service:/
'''
So I'm obviously just messing up how to get the PASSWORD env variable to spit out properly into the single quotes.
I seem to have tried a few thousand options so far, does anyone have any bright ideas?
Thanks in advance
Try without single quotes.
sshpass -p ${PASSWORD} scp ${WORKSPACE}/target/citest-1.0-SNAPSHOT.jar root@target_service:/
Is there any specific reason to keep it in single Quotes? because single quote will not interpolate variable.