Github与Hudson CI集成

时间:2011-07-26 19:57:02

标签: github hudson-plugins

本着开放的精神,我是Hudson CI的新手,Github也请我这么做。这是我到目前为止所做的。

  • 将tomcat6.0服务器部署到c:\ www
  • 在c:\ www \ webapps文件夹
  • 中下载并部署了Hudson.war
  • 安装了Github插件
  • 在Github上创建了一个私人存储库
  • 在服务器上,安装了hudson,生成了ssh密钥。
  • 环境变量%HOME%设置为c:\ Documents and settings [username](带有键的.ssh目录)
  • 环境变量%HUDSON_HOME%设置为c:\ www \ webapps \ hudson
  • 在哈德森,我有以下配置:
    • Github项目:https://github.com/ [my organization] / [项目名称]
    • 源代码管理:Git
    • 存储库的URL:git@github.com:[我的组织] / [项目名称] .git
    • 分支说明符:**
    • 资源库浏览器:(自动)

当我运行构建,并单击控制台输出链接时,我看到了这个 -

Started by user anonymous
Checkout:workspace / C:\www\webapps\hudson\jobs\[project name] (git)\workspace - hudson.remoting.LocalChannel@2e8f6d20
Using strategy: Default
Checkout:workspace / C:\www\webapps\hudson\jobs\[project name] (git)\workspace - hudson.remoting.LocalChannel@2e8f6d20
Fetching changes from the remote Git repository
Fetching upstream changes from git@github.com:[organization name]/[project name].git

......它挂起了。取消构建时,会添加以下内容 -

ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR:  (Underlying report) : Error performing command: git.exe fetch -t git@github.com:[organization name]/[project name].git +refs/heads/*:refs/remotes/origin/*
null
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
    at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:796)
    at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:754)
    at hudson.FilePath.act(FilePath.java:756)
    at hudson.FilePath.act(FilePath.java:738)
    at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:754)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:540)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1180)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:506)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:422)
    at hudson.model.Run.run(Run.java:1362)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145)

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:2)

首先,由于您开始使用新的CI实例,我强烈建议您安装Jenkins分叉(因为它是由Hudson的大多数原始开发人员主动维护的)。

其次,安装DumpInfo Wrapper plugin并重新运行构建。此插件在构建期间打印有效的系统属性和环境变量,并允许您验证它们。

更新

该插件应该记录系统属性和环境变量,我很惊讶你没有看到它们。至于密码,我建议您生成一个单独的私钥(来自您现有的对),而不是密码保护,否则您可能需要考虑为Why git can't remember my passphrase under Windows提供的解决方案。我已经验证它有效(当我在Windows上设置自己的CI时)但我觉得不值得麻烦(还有其他细微差别,包括安装和运行tomcat实例作为当前登录用户,而不是本地服务,以便选美会正确使用它,因此我会推荐第一个选项。

答案 1 :(得分:0)

在我的情况下,它结果是Git客户端的问题:我使用的是v1.6.0,它正在触发

fatal: https://github.com/dmak/jaxb-xew-plugin.git/info/refs download error - The requested URL returned error: 403

Hudson中的

错误消息。首先,它看起来像this issue,但{gid运行显示的strace分析是Nginx WebServer(运行GitHub)返回403,而不是代理。

当我更新到v1.7.3时,问题就消失了。所以一般建议:不要将旧客户端与GitHub一起使用。

P.S。我已经在Hudson作业配置中使用“Branch Specifier(默认为空白):origin / master”以及空白(默认)测试了克隆:在这两种情况下,Git都能够正确地发现主分支(origin / master)和用它来克隆。