请参阅以下詹金斯管道脚本
sshagent(['sshuser']) {
sh "git clone ssh://git@git.local.com/test/test-commit.git"
}
我一直在跟踪詹金斯的日志
Cloning into 'test-commit'...
Host key verification failed.
fatal: Could not read from remote repository.
尝试了一些技巧来自动接受主机验证,但都失败了,非常沮丧。
答案 0 :(得分:1)
如果您主要关注git,则可以使用GIT_SSH_COMMAND
环境变量。它允许您注入ssh选项:
stage('My git stage') {
environment {
GIT_SSH_COMMAND = "ssh -o StrictHostKeyChecking=no"
}
steps {
sshagent(['sshuser']) {
sh "git clone ssh://git@git.local.com/test/test-commit.git"
}
}
}
请注意,这带有一些安全问题。您可能要调查:https://www.symantec.com/connect/articles/ssh-host-key-protection