Git PullRequest 作业失败。找不到任何要构建的修订版。验证此作业的存储库和分支配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23906352/
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
Git PullRequest job failed. Couldn't find any revision to build. Verify the repository and branch configuration for this job
提问by Vladimir Voitekhovski
Yesterday my pullrequest jobs failed with the following output:
昨天我的 pullrequest 作业失败,输出如下:
11:07:41 > git rev-parse origin/${sha1}^{commit}
11:07:41 > git rev-parse ${sha1}^{commit}
11:07:41 ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
I have made an investigation and saw that in property ${sha1} there was nothing. When i paste an absolute path to pull request builder like pr/341/merge instead of ${sha1} the build works. What it can be?
我进行了调查,发现在财产 ${sha1} 中什么也没有。当我将绝对路径粘贴到像 pr/341/merge 这样的拉取请求构建器而不是 ${sha1} 时,构建工作。它可以是什么?
Git Client Plugin 1.9.0
Git 客户端插件 1.9.0
GitHub API Plugin 1.44
GitHub API 插件 1.44
回答by Tammytee
I spent a long time on this. The above comment "if I leave this field blank" worked like a charm. In SCM:
1) select Git
2) Name: origin
3) Refspec: +refs/pull/*:refs/remotes/origin/pr/*
4) Branches to build : leave blank
我在这上面花了很长时间。上面的评论“如果我将此字段留空”就像一个魅力。在 SCM 中:
1) 选择 Git
2) 名称:origin
3) Refspec:+refs/pull/*:refs/remotes/origin/pr/*
4) 要构建的分支:留空
This solved the above error.
这解决了上述错误。
回答by xialin
As stated here, If you want to manually build the job, in the job setting check This build is parameterizedand add string parameter named sha1
with a default value of master
. When starting build give the sha1 parameter commit id you want to build or refname (eg: origin/pr/9/head).
如前所述在这里,如果你想手动建设工作,在岗位设置检查这个build参数并添加一个名为字符串参数sha1
用的默认值master
。开始构建时,请提供要构建的 sha1 参数提交 ID 或引用名称(例如:origin/pr/9/head)。
回答by Satish patil
sometimes this happens if "Branch Specifier" is not set properly. I corrected specifier and it worked for me.
如果“分支说明符”设置不正确,有时会发生这种情况。我更正了说明符,它对我有用。
*/release/release4.5.0
or
或者
*/feature/myfeature
回答by sonny
I fixed this same error message by using the refs/heads/<branchName>
syntax in the "Branches to build - branch specifier".
我通过使用refs/heads/<branchName>
“Branches to build-branch specifier”中的语法修复了同样的错误消息。
For example, instead of origin/master
, I put refs/remotes/origin/master
as the branch specifier to fix the job.
例如,origin/master
我将, 而不是,refs/remotes/origin/master
作为分支说明符来修复工作。
(In my case, I'm not sure what caused this error message to appear, as the job was previously working fine with just origin/master
as the branch specifier. It may have been a related update or configuration change...)
(在我的情况下,我不确定是什么导致出现此错误消息,因为该作业以前与origin/master
分支说明符一样工作正常。它可能是相关的更新或配置更改......)
Note that you can use git show-ref
command to list references in a local repository, e.g.
请注意,您可以使用git show-ref
命令列出本地存储库中的引用,例如
git show-ref master
28f1f186807d1316bf1c59631d6d8825a5087e27 refs/heads/master
28f1f186807d1316bf1c59631d6d8825a5087e27 refs/remotes/origin/master
Also, the "?" help documentation next to 'Branch Specifier' field also supports this answer as the safest option for specifying the branch specifier to make sure the expected branch is unambiguous:
还有,“?” “分支说明符”字段旁边的帮助文档也支持将此答案作为指定分支说明符以确保预期分支明确无误的最安全选项:
Specify the branches if you'd like to track a specific branch in a repository. If left blank, all branches will be examined for changes and built.
The safest way is to use the refs/heads/<branchName> syntax. This way the expected branch is unambiguous.
Possible options:
<branchName>
Tracks/checks out the specified branch. If ambiguous the first result is taken, which is not necessarily the expected one. Better use refs/heads/<branchName>.
E.g. master, feature1,...
refs/heads/<branchName>
Tracks/checks out the specified branch.
E.g. refs/heads/master, refs/heads/feature1/master,...
<remoteRepoName>/<branchName>
Tracks/checks out the specified branch. If ambiguous the first result is taken, which is not necessarily the expected one.
Better use refs/heads/<branchName>.
E.g. origin/master
remotes/<remoteRepoName>/<branchName>
Tracks/checks out the specified branch.
E.g. remotes/origin/master
refs/remotes/<remoteRepoName>/<branchName>
Tracks/checks out the specified branch.
E.g. refs/remotes/origin/master
<tagName>
This does not work since the tag will not be recognized as tag.
Use refs/tags/<tagName> instead.
E.g. git-2.3.0
refs/tags/<tagName>
Tracks/checks out the specified tag.
E.g. refs/tags/git-2.3.0
<commitId>
Checks out the specified commit.
E.g. 5062ac843f2b947733e6a3b105977056821bd352, 5062ac84, ...
${ENV_VARIABLE}
It is also possible to use environment variables. In this case the variables are evaluated and the result is used as described above.
E.g. ${TREEISH}, refs/tags/${TAGNAME},...
<Wildcards>
The syntax is of the form: REPOSITORYNAME/BRANCH. In addition, BRANCH is recognized as a shorthand of */BRANCH, '*' is recognized as a wildcard, and '**' is recognized as wildcard that includes the separator '/'. Therefore, origin/branches* would match origin/branches-foo but not origin/branches/foo, while origin/branches** would match both origin/branches-foo and origin/branches/foo.
:<regular expression>
The syntax is of the form: :regexp. Regular expression syntax in branches to build will only build those branches whose names match the regular expression.
回答by Harsimran Singh
I came across the same issue and spent 4 hours into it but finally got it resolved.
我遇到了同样的问题并花了 4 个小时解决它,但最终得到了解决。
In my case, error was because of wrong Git exe. Inside Jenkins, while setting Git exe path on windows, set the path under cmd folder
就我而言,错误是因为错误的 Git exe。在Jenkins内部,在windows上设置Git exe路径时,设置cmd文件夹下的路径
In my case it was C:\Program Files\Git\cmd\git.exe
就我而言,它是 C:\Program Files\Git\cmd\git.exe
It resolved my issue.
它解决了我的问题。
回答by Tilman Hausherr
I had the same problem. TIn my case, the cause was that I used a github repository that was a mirror of an svn repository (because svn is not properly supported by SonarCloud). The default in Jenkins was */master
. The solution (found by Gavin McDonald of Apache INFRA) was to use */trunk
. Another problem is the ".git" in the URL, that should not be used.
我有同样的问题。在我的例子中,原因是我使用了一个 github 存储库,它是一个 svn 存储库的镜像(因为 SonarCloud 没有正确支持 svn)。Jenkins 中的默认值是 */master
. 解决方案(由 Apache INFRA 的 Gavin McDonald 发现)是使用*/trunk
. 另一个问题是 URL 中的“.git”,不应使用。
回答by Elakya
Whenever we don't specify a correct branch to pull, the git will look for all the branches that repository has and end up throwing an error saying "Couldn't find any revision to build. Verify the repository and branch configuration for this job."
每当我们没有指定要拉取的正确分支时,git 将查找存储库拥有的所有分支,并最终抛出一个错误,提示“找不到要构建的任何修订版。验证此作业的存储库和分支配置。 ”
I had faced the same issue with my git pull and i was using jenkins to specify the configuration.
我的 git pull 遇到了同样的问题,我使用 jenkins 来指定配置。
If we leave it to blank, it would get the files from master branch, but if something is wrong or a typo is there, it would look for all branches and throw error saying branch not found.
如果我们将其留空,它将从 master 分支获取文件,但如果出现问题或有错别字,它将查找所有分支并抛出错误,提示未找到分支。
回答by Daljeeth Singh
After lots of research and head breaking. I was receiving the same error and I found out that this error also occurs if you are using a different git path. Make sure you have the correct path. For ex: I replaced C:\Program Files\Git\git-bash.exewith C:\Program Files\Git\bin\git.exeand this resolved the issue.
经过大量研究和头破。我收到了同样的错误,我发现如果您使用不同的 git 路径,也会发生此错误。确保你有正确的路径。例如:我 用C:\Program Files\Git\bin\git.exe替换了C:\Program Files\Git\git- bash.exe,这解决了问题。