Jenkins共享库:权限被拒绝(publickey)

时间:2018-05-13 17:27:32

标签: jenkins github jenkins-pipeline

我尝试在jenkins中动态加载共享库,在github上托管如下

library identifier: 'custom-lib@master', retriever: modernSCM(
  [$class: 'GitSCMSource',
   remote: 'ssh://git@github.com:papanito/jenkins-pipeline-helper.git',
   credentialsId: 'git'])

但是,这会因以下错误而失败

hudson.plugins.git.GitException: Command "git ls-remote -h -t git@github.com:papanito/jenkins-pipeline-helper.git" returned status code 128:
stdout: 
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

我使用的凭据有一个有效的私钥,并且在我通过Jenkins设置使用库时工作正常。但是,在管道中动态加载它不起作用。有什么线索的原因?

2 个答案:

答案 0 :(得分:1)

只需将你的密钥移动到一个文件夹中,然后给文件夹chmod 600级别访问权限。然后从该文件夹中添加密钥。 Ssh-add应该适合你。

答案 1 :(得分:0)

显然钥匙有问题。我已经将密钥重新添加到jenkins的凭证存储中,现在证明它可以正常工作。

相关问题