【问题标题】:Populating Jenkins workspace from Gerrit/Git从 Gerrit/Git 填充 Jenkins 工作区
【发布时间】:2013-08-23 12:19:24
【问题描述】:

我已经设置了 Gerrit-Git-Jenkins 组合。我正在为 Jenkis 使用以下插件。

  • 格里特触发器
  • Git 客户端插件
  • Jenkins GIT 插件

我正在运行一个虚拟的 Jenkins 工作,该工作对于开发目的总是成功的。我注意到,当我将更改推送到 Gerrit 时,文件不会显示在 Jenkins 工作区中。

在 Jenkins Git 配置中设置的存储库 URL 是 git://localhost/project 我已经尝试手动克隆它,git clone git://localhost/project 获得了我期望的文件。

Jenkins 克隆什么存储库来填充其工作区?

它克隆git://localhost/project。我已经通过运行git remote show origin 作为构建脚本对此进行了测试,然后查看了日志输出。

Jenkins 运行什么命令来填充工作区,因为它似乎不是 HEAD 的克隆?

【问题讨论】:

  • 我注意到工作区的 .git 中有一个 FETCH_HEAD 文件。 FETCH_HEAD 保存对正确存储库的引用。似乎工作区没有对获取的存储库执行checkout

标签: git jenkins jenkins-plugins gerrit


【解决方案1】:

Jenkins 执行以下操作来填充其工作区。 (中的名字代表Jenkins项目配置中的字段名):

git clone <Repository URL>
git fetch <Refspec>
git checkout <Branch Specifier>

使用 Gerrit 中等待验证的文件填充工作区的设置是:

Refspec: refs/changes/*:refs/changes/*
Branches to build: $GERRIT_REFSPEC

这会克隆来自 Gerrit 的 refs/changes/* 中的所有内容,并从引用为分支 $GERRIT_REFSPEC 的文件中填充工作区。 $GERRIT_REFSPEC 对于 Gerrit 收到的每个新更改都不同,它看起来像这样 refs/changes/05/5/1

【讨论】:

    【解决方案2】:

    为了记录,要检查 Gerrit 审查请求(即特定的补丁集),请在 Jenkins/Hudson 作业中配置以下 3 个配置选项:

    1. Repositories -&gt; Repository URL: gerrit 项目的 git url
      (例如,http://gerrit.corp.com/the-project

    2. Repositories -&gt; Refspec(高级 Git 设置):refs/changes/*:refs/changes/*

    3. Branches to be built -&gt; Branch Specifier):refs/changes/XY/??XY/?
      (例如,refs/changes/24/3124/8

    艾伦的回答是正确的。只是不够清楚,恕我直言,这就是为什么我试图用换句话说来详细说明答案。

    【讨论】:

      猜你喜欢
      • 2012-01-14
      • 2013-07-12
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多