I am trying to push some changes to the git repository using groovy pipeline syntax. But I am unable to push. Can anyone help me here.
Pipeline Syntax:
sh '''
#git checkout pkg_version
touch README
git add .
git status
git commit -m "Updated Package Version"
git remote -v
sshagent(credentialsId) {
git push origin pkg_version
}
#git push origin pkg_version
'''
Jenkins Error:
origin ssh://jenkins@gerrit:29418/sfdx_nar (fetch)
origin ssh://jenkins@gerrit:29418/sfdx_nar (push)
+ git push origin pkg_version
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
[Pipeline] }
Try using SSHAgent like this in your pipeline:
steps{
sshagent(['your-credential-id']) {
sh "git-steps..."
}
}