I have a basic Pipeline that copies a directory to a remote directory. If i have the username and password in plain text it works fine, but when I try to use withCredentials I get authentication errors. Is there a certain syntax to reference this? Pipeline is as below
node {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'creds-id', usernameVariable: 'username', passwordVariable: 'password']]){
def remote = [:]
remote.name = 'EU Server 1'
remote.host = 'server1@server.com'
remote.user = '$username'
remote.password = '$password'
remote.allowAnyHosts = true
stage('Copy dir to server'){
sshPut remote: remote, from: '/data/workspace', into: '/home/server1/workspace1'
}
}
I'm getting the error below
com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:519)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.jcraft.jsch.Session$connect$6.call(Unknown Source)