Jenkins和Git配置问题

时间:2014-10-30 07:19:49

标签: git jenkins jenkins-plugins

我一直在使用Git。

最近,我开始探索Jenkins,并设法使用本机Windows安装程序进行设置。我在本地系统上创建了一个示例项目,并使用Jenkins成功构建了它。

现在,我在远程服务器上有一个项目,我希望Jenkins使用Git来提取此代码。

我做了以下事情:

1)安装了Git插件。 enter image description here

2)在Jenkins>管理Jenkins>配置系统> Git> Git安装 -

enter image description here

[还试过C:\ Program Files(x86)\ Git \ cmd \ gitk.cmd而不是.... \ git.exe]

3)在测试项目下>配置 enter image description here

4)最后,尝试构建它。但总是得到超时错误,然后失败。 enter image description here

Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\GitTest
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\cmd\git.exe config remote.origin.url ssh://git@<the-url-to-the-server>demo_android.git # timeout=10
Fetching upstream changes from ssh://git@<the-url-to-the-server>demo_android.git
 > C:\Program Files (x86)\Git\cmd\git.exe --version # timeout=10
 > C:\Program Files (x86)\Git\cmd\git.exe fetch --tags --progress ssh://git@<the-url-to-the-server>demo_android.git +refs/heads/*:refs/remotes/origin/* # timeout=60
FATAL: Failed to fetch from ssh://git@<the-url-to-the-server>demo_android.git
hudson.plugins.git.GitException: Failed to fetch from ssh://git@<the-url-to-the-server>demo_android.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:647)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:889)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:914)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1258)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
    at hudson.model.Run.execute(Run.java:1759)
    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 "C:\Program Files (x86)\Git\cmd\git.exe fetch --tags --progress ssh://git@<the-url-to-the-server>demo_android.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host git.us1.adeptra.com port 7999: Bad file number
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1435)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1223)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:85)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:280)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:645)
    ... 10 more

我做错了什么?我需要提供凭据吗? (我试过它也失败了)

3 个答案:

答案 0 :(得分:1)

解决了! SSH密钥有密码。我删除它,它工作正常。

按照链接中的说明删除密码 -

http://www.thinkplexx.com/learn/howto/security/ssl/remove-passphrase-password-from-private-rsa-key

答案 1 :(得分:0)

您需要提供身份验证。要么使用纯文本并将其填入配置或命令行,要么使用证书 ssh-public-key来执行此操作。

在这里你可以找到关于如何将它连接到GitHub的 a tutorial ,我认为它应该在你自己的 git-server 上完成。

答案 2 :(得分:0)

只需进入 jenkins -> 全局工具配置 -> 添加 git -> 名称(默认)和 Git 可执行文件(git)的路径 -> 保存