Jenkins,主机密钥验证失败,脚本返回退出代码255

时间:2017-12-02 14:22:18

标签: jenkins ssh jenkins-pipeline

我有一个building-server,我有Jenkins 2.73.3以及我部署应用程序的其他服务器。

我还设置了从building-server连接到其他服务器的凭据。

但每次我添加另一台服务器时都很难添加它,因为我在新服务器和命令行中设置了授权密钥,但在Jenkins中却没有。

这是一个失败的小配方:

pipeline {
  agent any

  stages {

    stage('Set conditions') {
      steps {
        sshagent(['xxxx-xxxx-xxxx-xxxx-xxxx']) {
          sh "ssh user@product.company.com 'echo $HOME'"
        }
      }
    }

  }
}

这是日志失败:

[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
[check] Running shell script
+ ssh user@product.company.com echo /var/lib/jenkins
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 12567 killed;
[ssh-agent] Stopped.
Host key verification failed.
[Pipeline] }
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 255
Finished: FAILURE

1 个答案:

答案 0 :(得分:3)

似乎解决方案是将参数StrictHostKeyChecking添加到shell脚本行

rmarecord.setCurrentLineItemValue('item', 'serialnumbers',datain.serial);
相关问题