【问题标题】:Jenkins, git, submodules with custom URL (SSH)Jenkins、git、带有自定义 URL (SSH) 的子模块
【发布时间】:2012-06-04 16:24:07
【问题描述】:

问题很简单:Jenkins 可以使用 ssh://ci_ro@server 访问主 git 存储库(效果很好),但我有 URL 不同的子模块:ssh: //server (没有定义一些用户,这是为了让开发人员可以使用这个 repo 及其子模块)。我绝对不允许(坦率地说不想)提交 CI 特定的 .gitmodule 文件(这会破坏开发人员的存储库),所以请不要提及它。所以 Jenkins 可以提取主仓库,但立即失败:

Caused by: hudson.plugins.git.GitException: Command "git submodule update --init --recursive" returned status code 1: Cloning into blah/blah...
Host key verification failed.
fatal: The remote end hung up unexpectedly
Clone of 'ssh://server:someport/blah/blah...' into submodule path 'blah/blah' failed

我的问题:是否可以告诉 Jenkins 使用 ssh://ci_ro@server... 子模块的 URL 前缀而不是 .gitmodules 中配置的前缀?或者任何其他可用的解决方法、插件或黑客?我浏览了工作选项,没有找到任何有用的选项。

更新

感谢所有帮助的人。解决方案是允许“jenkins”系统用户使用 git 从特定的 ssh 服务器/端口拉取。

【问题讨论】:

标签: git ssh jenkins


【解决方案1】:

解决方案是允许运行 Jenkins 的系统用户使用 SSH 从指定的主机/端口拉取。

【讨论】:

  • 表示为jenkins生成ssh密钥并在github中添加公钥
  • 非常感谢您的解决方案
【解决方案2】:

您始终可以从 shell 构建步骤手动完成。

【讨论】:

  • 构建立即在开始时挂起,因此没有机会进行构建步骤。此外,禁用递归子模块更新也无济于事。
  • 我的意思是根本不使用插件。
【解决方案3】:

尝试更改构建服务器上的 /etc/ssh/ssh_config:

    StrictHostKeyChecking no

【讨论】:

    【解决方案4】:

    在你的构建步骤中,做一个

    git submodule init
    

    然后递归子模块并调整它们的遥控器,这是不对的,但是我在 github 用户名更改时使用的脚本是:

    #!/bin/sh
    git remote -v | grep richoH | while read name url type; do
        newurl=`echo $url | sed -e "s/richoH/richo/"`
        git remote set-url $name $newurl
    done
    

    然后进行 git 子模块更新,我认为这不会干扰遥控器。这是未经测试的,但我相信是正确的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-08
      • 2015-07-30
      • 2014-01-23
      • 2011-08-27
      • 1970-01-01
      • 2013-03-10
      • 2014-09-26
      相关资源
      最近更新 更多