git Jenkins 的 Gerrit 触发器找不到任何要构建的修订版
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29034240/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gerrit trigger for Jenkins couldn't find any revision to build
提问by MisterPatate
I have trouble using Jenkins+Gerrit.
我在使用 Jenkins+Gerrit 时遇到问题。
Here is what I got so far:
这是我到目前为止所得到的:
Gerrit Trigger configuration in Jenkins seems to be ok: When I push a new changeset, Jenkins build is launched.
I used this: Jenkins: settings for Gerrit Trigger problemsto also be able to launch it "manually".
As for my configuration, I have something like this: https://stackoverflow.com/a/18347982/2248987. Branch Specifier is $GERRIT_BRANCH and Ref Spec is $GERRIT_REFSPEC
Gerrit and Git are working fines on their own. Access seems OK too.
Jenkins 中的 Gerrit Trigger 配置似乎没问题:当我推送新的变更集时,Jenkins 构建启动。
我使用了这个: Jenkins:Gerrit Trigger 问题的设置也能够“手动”启动它。
至于我的配置,我有这样的东西:https: //stackoverflow.com/a/18347982/2248987。分支说明符是 $GERRIT_BRANCH,参考规范是 $GERRIT_REFSPEC
Gerrit 和 Git 自己工作得很好。访问似乎也可以。
Here is my issue. When building (gerrit triggered or manually), log output is:
这是我的问题。构建时(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
I am stuck with this message, tried with empty repo, non-empty ones, and also with or without changeset "in review"
我被这条消息困住了,尝试使用空的 repo、非空的 repo,以及带有或不带有“正在”的变更集
采纳答案by Samuel Kerrien
I used to have this problem and I think I have now fixed it, I am blaming the Jenkins UI for hiding some essential configuration elements ;)
我曾经遇到过这个问题,我想我现在已经解决了,我指责 Jenkins UI 隐藏了一些基本的配置元素;)
Here is the output of my Jenkins build prior to the fix:
这是修复之前我的 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
SOLUTION
解决方案
You will need to open your build configuration and go to the section 'Source Code Management' as shown below:
您需要打开构建配置并转到“源代码管理”部分,如下所示:
Now you will notice that there is a button 'Advanced', click it to reveal the extra fields as below:
现在您会注意到有一个“高级”按钮,单击它以显示以下额外字段:
Now you can type your refspec here: $GERRIT_REFSPEC
现在您可以在此处输入您的 refspec:$GERRIT_REFSPEC
Now either retrigger a failed build or abandon reviews and submit a new one and it should be working.
现在要么重新触发失败的构建,要么放弃并提交新的,它应该可以正常工作。
Here is the output of the Jenkins job now that we have the appropriate 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
回答by rahul srivastav
- Leave the 'Branches to build > Branch specifier' field blank
- Click the Advanced button, and set a custom refspec: +refs/heads/feature/my-feature:refs/remotes/origin/feature/my-featureWith these settings, the plugin will correctly perform a fetch and then check out only the 'feature/my-feature' branch.
- 将“要构建的分支 > 分支说明符”字段留空
- 单击高级按钮,并设置自定义 refspec: +refs/heads/feature/my-feature:refs/remotes/origin/feature/my-feature使用这些设置,插件将正确执行提取,然后仅检查“功能/我的功能”分支。
回答by Flows
You could try to configure like that
你可以尝试这样配置
- Refspec= refs/changes/:refs/changes/
- Branches to build= $GERRIT_REFSPEC
- Refspec= refs/changes/:refs/changes/
- 要构建的分支= $GERRIT_REFSPEC
Follow the full configuration there
If you click "Build Now", Jenkins won't be able to get sources since $GERRIT_REFSPEC doesn't exist on that case.
如果您单击“立即构建”,Jenkins 将无法获取源代码,因为在这种情况下 $GERRIT_REFSPEC 不存在。
回答by Abhishek Mishra
After lot's of struggle and keeping eye on log,finally I got the solution.
经过大量的斗争和关注日志,我终于找到了解决方案。
It's just configuration mistake that we all did. Once checked check box This project is parameterizedBelow configuration need to be done
这只是我们所做的配置错误。一旦选中复选框此项目已参数化下面需要进行配置
Here I named parameter name as branchgitNow in Source Code Management we need to concentrate on Branches to buildwhose value should be only "$branchgit" as per below image
在这里,我将参数名称命名为branchgit现在在源代码管理中,我们需要专注于构建分支,其值应仅为“$branchgit”,如下图所示
回答by Anndy Dong
The following settings worked for me: Fill Refspec with $GERRIT_REFSPEC in "Advanced" section. "Branch Specifier" can be blank or any valid value
以下设置对我有用:在“高级”部分用 $GERRIT_REFSPEC 填充 Refspec。“分支说明符”可以是空白或任何有效值
回答by uncletall
Replace $GERRIT_BRANCH
with $GERRIT_REFSPEC
替换$GERRIT_BRANCH
为$GERRIT_REFSPEC