簡體   English   中英

使用憑據插件運行Jenkins管道步驟的問題

[英]Issue running Jenkins Pipeline Steps using Credentials plugin

我有一個將目錄復制到遠程目錄的基本管道。 如果我的用戶名和密碼為純文本格式,則可以正常工作,但是當我嘗試使用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)

這樣做的方法是調用不帶引號或$的變量,如下所示

def remote = [:]
remote.name = 'EU Server 1'
remote.host = 'server1@server.com'
remote.user = username
remote.password = password
remote.allowAnyHosts = true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM