Refer to following jenkins pipeline script
sshagent(['sshuser']) {
sh "git clone ssh://[email protected]/test/test-commit.git"
}
I am always getting following logs in jenkins
Cloning into 'test-commit'...
Host key verification failed.
fatal: Could not read from remote repository.
Tried a few tricks to auto accept the host verification but all failed, very frustrated.
If your main concern is with git you could use the GIT_SSH_COMMAND
environment variable. It allows you to inject ssh options:
stage('My git stage') {
environment {
GIT_SSH_COMMAND = "ssh -o StrictHostKeyChecking=no"
}
steps {
sshagent(['sshuser']) {
sh "git clone ssh://[email protected]/test/test-commit.git"
}
}
}
Mind you, this comes with some security concerns. You might want to investigate: https://www.symantec.com/connect/articles/ssh-host-key-protection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With