Jenkins,bit bucket和Vagrant:无法登录git

时间:2014-01-30 23:05:53

标签: git symfony ssh jenkins

我想将Jenkins集成到我的Symfony 2项目中,该项目位于BitBucket存储库中。

我在我的Vagrant虚拟机上安装了Jenkins,然后配置了一个作业。

因此,在源代码管理中,我选择了Git,并在“存储库URL”(git@bitbucket.org:me/myproject.git)中设置了BitBucket SSH URL。然后,在我的Vagrant框中记录为jenkins,我生成了一个SSH密钥,并将id_rsa.pub复制到BitBucket中的新SSH公钥中。我在Jenkins作业git配置中添加了这个密钥作为credidential(用户名作为我的BitBucket用户名)。

当我尝试构建项目时,Jenkins向我显示了这个错误:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/api/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from git@bitbucket.org:myuser/myproject.git
using GIT_SSH to set credentials 
FATAL: Failed to fetch from git@bitbucket.org:myuser/myproject.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:myuser/myproject.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:625)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:847)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:872)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:651)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:560)
    at hudson.model.Run.execute(Run.java:1670)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:231)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:myuser/myproject.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly

你知道发生了什么吗? 谢谢!

1 个答案:

答案 0 :(得分:1)

因为远程服务器拒绝了你的公钥。日志告诉你=> stderr: Permission denied (publickey).

执行此操作,前往~/.ssh创建名为config的文件并添加以下内容,确保这些值反映您的个人设置。

Host bitbucket.org
    User myuser
    Hostname bitbucket.org
    IdentityFile /home/myuser/.ssh/id_rsa

然后重新开始。