Jenkins 的 Gerrit 触发器找不到要构建的任何修订
Gerrit trigger for Jenkins couldn't find any revision to build
我在使用 Jenkins+Gerrit 时遇到了问题。
这是我目前得到的:
Jenkins 中的 Gerrit 触发器配置似乎没问题:当我推送新的变更集时,Jenkins 构建启动。
我用过这个:
Jenkins: settings for Gerrit Trigger problems
也能够启动它 "manually".
至于我的配置,我有
像这样:。 Branch Specifier 是 $GERRIT_BRANCH,Ref Spec 是 $GERRIT_REFSPEC
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
我被这条消息卡住了,尝试过空回购、非空回购以及有或没有变更集 "in review"
将$GERRIT_BRANCH
替换为$GERRIT_REFSPEC
- 将 'Branches to build > Branch specifier' 字段留空
- 单击“高级”按钮,并设置自定义参考规范:
+refs/heads/feature/my-feature:refs/remotes/origin/feature/my-feature
使用这些设置,插件将正确执行提取,然后仅检出 'feature/my-feature' 分支。
我曾经遇到过这个问题,我想我现在已经解决了,我责怪 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
解决方案
您需要打开构建配置并转到 'Source Code Management' 部分,如下所示:
现在您会注意到有一个按钮 'Advanced',单击它可以显示额外的字段,如下所示:
现在您可以在此处输入您的参考规范:$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
你可以尝试这样配置
- 参考规格 = refs/changes/:refs/changes/
- 要构建的分支 = $GERRIT_REFSPEC
关注
如果您单击“立即构建”,Jenkins 将无法获取源代码,因为 $GERRIT_REFSPEC 在这种情况下不存在。
经过大量的努力和关注日志,终于找到了解决方案。
这只是我们都犯过的配置错误。
选中复选框后 此项目已参数化
需要完成以下配置
这里我将参数名命名为branchgit
现在在源代码管理中,我们需要专注于要构建的分支,其值应该仅为“$branchgit”,如下图所示
以下设置对我有用:
在 "Advanced" 部分用 $GERRIT_REFSPEC 填充 Refspec。
"Branch Specifier" 可以为空或任何有效值
我在使用 Jenkins+Gerrit 时遇到了问题。
这是我目前得到的:
Jenkins 中的 Gerrit 触发器配置似乎没问题:当我推送新的变更集时,Jenkins 构建启动。
我用过这个: Jenkins: settings for Gerrit Trigger problems 也能够启动它 "manually".
至于我的配置,我有 像这样:。 Branch Specifier 是 $GERRIT_BRANCH,Ref Spec 是 $GERRIT_REFSPEC
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
我被这条消息卡住了,尝试过空回购、非空回购以及有或没有变更集 "in review"
将$GERRIT_BRANCH
替换为$GERRIT_REFSPEC
- 将 'Branches to build > Branch specifier' 字段留空
- 单击“高级”按钮,并设置自定义参考规范: +refs/heads/feature/my-feature:refs/remotes/origin/feature/my-feature 使用这些设置,插件将正确执行提取,然后仅检出 'feature/my-feature' 分支。
我曾经遇到过这个问题,我想我现在已经解决了,我责怪 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
解决方案
您需要打开构建配置并转到 'Source Code Management' 部分,如下所示:
现在您会注意到有一个按钮 'Advanced',单击它可以显示额外的字段,如下所示:
现在您可以在此处输入您的参考规范:$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
你可以尝试这样配置
- 参考规格 = refs/changes/:refs/changes/
- 要构建的分支 = $GERRIT_REFSPEC
关注
如果您单击“立即构建”,Jenkins 将无法获取源代码,因为 $GERRIT_REFSPEC 在这种情况下不存在。
经过大量的努力和关注日志,终于找到了解决方案。
这只是我们都犯过的配置错误。 选中复选框后 此项目已参数化 需要完成以下配置
这里我将参数名命名为branchgit
现在在源代码管理中,我们需要专注于要构建的分支,其值应该仅为“$branchgit”,如下图所示
以下设置对我有用: 在 "Advanced" 部分用 $GERRIT_REFSPEC 填充 Refspec。 "Branch Specifier" 可以为空或任何有效值