小编典典

詹金斯的Gerrit触发器找不到要构建的任何修订

jenkins

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

  • Gerrit和Git自己在罚款。访问似乎也可以。

这是我的问题。构建时(触发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

我被此消息所困扰,尝试使用空仓库,非空仓库以及是否有变更集“正在审核”


阅读 294

收藏
2020-07-25

共1个答案

小编典典

我曾经遇到过这个问题,我想我现在已经解决了,我指责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配置

现在,您会注意到有一个“高级”按钮,单击它会显示以下额外字段:

显示带有refspec字段的Git配置

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

现在,要么重新触发失败的构建,要么放弃评论并提交新的,它应该可以正常工作。

现在有了适当的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
2020-07-25