Jenkins的Gerrit触发器无法找到任何修改版本

时间:2015-03-13 14:02:36

标签: git jenkins gerrit gerrit-trigger

我在使用Jenkins + Gerrit时遇到了麻烦。

这是我到目前为止所得到的:

这是我的问题。构建时(gerrit触发或手动),日志输出为:

 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url ssh://user@host:29418/testproject # timeout=10
Fetching upstream changes from ssh://user@host:29418/testproject
 > git --version # timeout=10
using GIT_SSH to set credentials 
 > git -c core.askpass=true fetch --tags --progress ssh://user@host:29418/testproject refs/heads/master
 > git rev-parse origin/$GERRIT_BRANCH^{commit} # timeout=10
 > git rev-parse $GERRIT_BRANCH^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE

我坚持使用此消息,尝试使用空的回购,非空的回复,以及有或没有变更设置“在审核中”

6 个答案:

答案 0 :(得分:12)

我曾经有过这个问题,我想我现在已经解决了这个问题,我责备Jenkins UI隐藏了一些基本的配置元素;)

以下是修复之前我的Jenkins构建的输出:

Triggered by Gerrit: https://bbpcode.epfl.ch/code/15056
[EnvInject] - Loading node environment variables.
Building remotely on rh6.6-02 (amd64-RedHatEnterpriseServer 6.6 RedHatEnterpriseServer amd64-RedHatEnterpriseServer-6.6 rh6.x RedHatEnterpriseServer-6.6 amd64) in workspace /var/tmp/jenkins/workspace/datamining.nip-commons.gerrit
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url ssh://bbpcode.epfl.ch/datamining/nip-commons # timeout=10
Fetching upstream changes from ssh://bbpcode.epfl.ch/datamining/nip-commons
 > /usr/bin/git --version # timeout=10
 > /usr/bin/git fetch --tags --progress ssh://bbpcode.epfl.ch/datamining/nip-commons +refs/heads/*:refs/remotes/origin/*
 > /usr/bin/git rev-parse 74e4ff18f54bd6e046f7af016614193f566adfe4^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

<强>解

您需要打开构建配置并转到“源代码管理”部分,如下所示:

Git config with Advanced button

现在你会注意到有一个“高级”按钮,点击它可以显示如下的额外字段:

Git config with refspec field revealed

现在您可以在此输入您的refspec:$ GERRIT_REFSPEC

现在要么重新启动失败的构建版本,要么放弃评论并提交新版本,它应该正常工作。

以下是Jenkins作业的输出,现在我们有了相应的refspec:

Retriggered by user kerrien for Gerrit: https://bbpcode.epfl.ch/code/15056
[EnvInject] - Loading node environment variables.
Building remotely on rh6.6-02 (amd64-RedHatEnterpriseServer 6.6 RedHatEnterpriseServer amd64-RedHatEnterpriseServer-6.6 rh6.x RedHatEnterpriseServer-6.6 amd64) in workspace /var/tmp/jenkins/workspace/datamining.nip-commons.gerrit
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url ssh://bbpcode.epfl.ch/datamining/nip-commons # timeout=10
Fetching upstream changes from ssh://bbpcode.epfl.ch/datamining/nip-commons
 > /usr/bin/git --version # timeout=10
 > /usr/bin/git fetch --tags --progress ssh://bbpcode.epfl.ch/datamining/nip-commons refs/changes/56/15056/2
 > /usr/bin/git rev-parse 74e4ff18f54bd6e046f7af016614193f566adfe4^{commit} # timeout=10
Checking out Revision 74e4ff18f54bd6e046f7af016614193f566adfe4 (dev)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f 74e4ff18f54bd6e046f7af016614193f566adfe4
 > /usr/bin/git rev-parse FETCH_HEAD^{commit} # timeout=10
 > /usr/bin/git rev-list 2649d51369413cef4dfb7ec50939945005514cfa # timeout=10
Cleaning workspace
 > /usr/bin/git rev-parse --verify HEAD # timeout=10
Resetting working tree
 > /usr/bin/git reset --hard # timeout=10
 > /usr/bin/git clean -fdx # timeout=10
Triggering datamining.nip-commons.gerrit » default
datamining.nip-commons.gerrit » default completed with result SUCCESS
Started calculate disk usage of build
Finished Calculation of disk usage of build in  2 second
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: SUCCESS

答案 1 :(得分:2)

  1. 保留&#39;分支构建&gt;分支说明符&#39;字段空白
  2. 单击“高级”按钮,然后设置自定义refspec: 的 +参/头/特征/我的特征:参/遥控器/来源/特征/我的特征 使用这些设置,插件将正确执行提取,然后只检查&#39;功能/我的功能&#39;分支。

答案 2 :(得分:1)

你可以尝试像那样配置

  • Refspec = refs / changes /:refs / changes /
  • 要建立的分支 = $ GERRIT_REFSPEC

关注full configuration there

如果您点击“立即构建”,Jenkins将无法获得来源,因为在这种情况下$ GERRIT_REFSPEC不存在。

答案 3 :(得分:0)

$GERRIT_BRANCH替换为$GERRIT_REFSPEC

答案 4 :(得分:0)

经过多次斗争并密切关注日志,最后我得到了解决方案。

这只是我们所做的配置错误。 选中后,复选框此项目已参数化 以下配置需要完成

enter image description here

这里我将参数名称命名为 branchgit 现在在源代码管理中,我们需要专注于分支构建,其值应该只是“$ branchgit”,如下图所示 enter image description here

答案 5 :(得分:0)

以下设置对我有用: 在“高级”部分中,用$ GERRIT_REFSPEC填充Refspec。 “分支说明符”可以为空白或任何有效值