I am trying to use ssh-agent to push commits to a remote git repository from a scripted Jenkins pipeline.
I have installed the plugin and have added the SSH private key to the Credentials section on Jenkins. THe following is a snippet from a Groovy class instantiated and called from the Jenkinsfile:
stages.sshagent(credentials:['26954b1f-2e32-4b4b-8923-3b7a9fbac6c9']) {
stages.sh "git push origin ${branchName}"
}
Note:stages is just a representation of the stage within the Jenkinsfile. The class compiles fine but show the following error message each time:
FATAL: [ssh-agent] Could not find specified credentials
If I use the credentials with the git client then it works fine but unfortunately this does not support git push.