I have a simple pipeline:
pipeline {
agent {
docker {
image 'python:3.8-alpine3.15'
}
}
...
steps {
withCredentials([sshUserPrivateKey(credentialsId: "repo", keyFileVariable: 'keyfile')]){
sh '''
set +x
eval `ssh-agent -s`
ssh-add ${keyfile}
git clone git@gitlab.com/blabla
'''
}
}
}
The errored output is:
Masking supported pattern matches of $keyfile
Agent pid 53
+ ssh-add **** (blabla@blabla.com)
...
Host key verification failed.
fatal: Could not read from remote repository.
I have tried the same steps with the same key step by step on the same machine and it works, the problem resides on the withCredentials binding. It is not viable to change to ssh-agent plugin.
Does anybody know what is wrong and why I can't load the credentials succesfully?