jenkins无法连接到git存储库

我不能以某种方式configurationgit存储库url,Jenkins可以访问它。

在“项目>configuration>源代码pipe理”下,我将存储库URL设置为“git @ store:repositories / testproject.git”

我得到这个错误:

Failed to connect to repository : Command "/usr/bin/git -c core.askpass=true ls-remote -h git@store:repositories/testproject.git HEAD" returned status code 128: stdout: stderr: Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

具有该URL的访问在shell上工作:

 jenkins@dilbert:~$ /usr/bin/git -c core.askpass=true ls-remote -h git@store:repositories/testproject.git git@store's password: 4fd35a4f528e2f2921a52cfd03918b7cbde3d253 refs/heads/master 

我被要求input密码,它的工作原理。

我将相同的密码关联到jenkins的凭据“git /”,我也试过“git @ store /”。 没有工作。

请注意,这不是关于github,而是关于本地git存储库。

更新:

将jenkins master的pub key添加到build slave,帮助configuration工作:

 ssh-copy-id jenkins@dilbert 

现在构build失败:

  > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > /usr/bin/git config remote.origin.url git@store:repositories/testproject.git # timeout=10 Fetching upstream changes from git@store:repositories/testproject.git > /usr/bin/git --version # timeout=10 > /usr/bin/git -c core.askpass=true fetch --tags --progress git@store:repositories/testproject.git +refs/heads/*:refs/remotes/origin/* ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from git@store:repositories/testproject.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016) at hudson.scm.SCM.checkout(SCM.java:484) at hudson.model.AbstractProject.checkout(AbstractProject.java:1270) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:609) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:531) at hudson.model.Run.execute(Run.java:1751) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git -c core.askpass=true fetch --tags --progress git@store:repositories/testproject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

商店是jenkins大师,dilbert是build立奴隶。 ssh从主人到奴隶的作品。

 jenkins@store:~$ ssh dilbert uptime 16:06:21 up 3 days, 18:53, 13 users, load average: 0,31, 0,38, 0,50 

任何想法如何debugging呢?

身份validation通过ssh工作。 你有没有把jenkins用户的公共ssh-key添加到你的git-server上的git-user?

让我知道如果你需要如何设置SSHauthentication的指示,我会在这里编辑这个职位。

/编辑:

很高兴你得到它运行。 我看了官方jenkins网站的configurationSSH部分的详细手册,但我找不到任何。

所以这里有一个快速的概述 – 让我知道如果这是你所需要的。

  1. jenkins slave(build筑机器)连接到git-server(jenkins master)
  2. build筑机器运行jenkins用户(例如jenkins @ dilbert:〜$)
  3. git-server作为git用户运行(例如git @ store:〜$)
  4. jenkins @ dilbert公钥需要放在git @ store authorized_keys中
  5. 运行jenkins@dilbert:~/.ssh$ ssh-copy-id git@store将jenkins @ dilbert ssh公钥复制到git服务器