【发布时间】:2019-01-14 19:24:15
【问题描述】:
我有一个将目录复制到远程目录的基本管道。如果我有纯文本的用户名和密码,它可以正常工作,但是当我尝试使用 withCredentials 时,我会遇到身份验证错误。是否有特定的语法来引用它?流水线如下
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'
}
}
我收到以下错误
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)
【问题讨论】:
标签: jenkins jenkins-plugins jenkins-pipeline