简体   繁体   English

Git PullRequest 作业失败。 找不到要构建的任何修订。 验证此作业的存储库和分支配置

[英]Git PullRequest job failed. Couldn't find any revision to build. Verify the repository and branch configuration for this job

Yesterday my pullrequest jobs failed with the following output:昨天我的 pullrequest 作业因以下 output 而失败:

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.我进行了调查,发现在财产 ${sha1} 中什么都没有。 When i paste an absolute path to pull request builder like pr/341/merge instead of ${sha1} the build works.当我将绝对路径粘贴到像 pr/341/merge 这样的拉取请求构建器而不是 ${sha1} 时,构建工作。 What it can be?它可以是什么?

Git Client Plugin 1.9.0 Git 客户端插件 1.9.0

GitHub API Plugin 1.44 GitHub API 插件 1.44

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 1)选择Git
2) Name: origin 2)名称: origin
3) Refspec: +refs/pull/*:refs/remotes/origin/pr/* 3) Refspec: +refs/pull/*:refs/remotes/origin/pr/*
4) Branches to build : leave blank 4)要建的分支:留空

This solved the above error.这解决了上述错误。

According to this , Github branch's default name have been changed from "master" to "main".根据,Github上分支的默认名字已经从“主人”到“主”改变。

So, when creating new jobs for a new repository, you have to set "main" as the branch name instead of "master".因此,在为新存储库创建新作业时,您必须将“main”设置为分支名称而不是“master”。

Note that github has way to set "master" (or any other name of your convenience) as default branch name.请注意,github 可以将“master”(或您方便的任何其他名称)设置为默认分支名称。

As stated here , If you want to manually build the job, in the job setting check This build is parameterized and add string parameter named sha1 with a default value of master .如前所述在这里,如果你想手动建设工作,在岗位设置检查这个build参数并添加一个名为字符串参数sha1用的默认值master When starting build give the sha1 parameter commit id you want to build or refname (eg: origin/pr/9/head).开始构建时,请提供要构建的 sha1 参数提交 ID 或引用名称(例如:origin/pr/9/head)。

I fixed this same error message by using the refs/heads/<branchName> syntax in the "Branches to build - branch specifier" .我通过使用 "Branches to build - branch specifier" 中的refs/heads/<branchName>语法修复了相同的错误消息。

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, eg请注意,您可以使用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.

You need to define branch name because Jenkins catches master by default and there is no master in GitHub, it's now main so in the case of GitHub you need to pass branch name also.您需要定义分支名称,因为 Jenkins 默认捕获 master,而 GitHub 中没有 master,它现在是 main,因此在 GitHub 的情况下,您还需要传递分支名称。

git branch: 'main', credentialsId: 'GithubCred', url: 'Your-Repo-URL'

It resolved my issue它解决了我的问题

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

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.我收到了同样的错误,我发现如果您使用不同的 git 路径,也会发生此错误。 Make sure you have the correct path.确保您有正确的路径。 For ex: I replaced C:\\Program Files\\Git\\git-bash.exe with C:\\Program Files\\Git\\bin\\git.exe and this resolved the issue.例如:我用C:\\Program Files\\Git\\bin\\git.exe替换了C:\\Program Files\\Git\\git- bash.exe ,这解决了问题。

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.就我而言,错误是因为错误的 Git exe。 Inside Jenkins, while setting Git exe path on windows, set the path under cmd folder在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.它解决了我的问题。

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).在我的例子中,原因是我使用了一个 github 存储库,它是一个 svn 存储库的镜像(因为 SonarCloud 没有正确支持 svn)。 The default in Jenkins was */master . Jenkins 中的默认值是*/master The solution ( found by Gavin McDonald of Apache INFRA ) was to use */trunk .解决方案(由 Apache INFRA 的 Gavin McDonald 发现)是使用*/trunk Another problem is the ".git" in the URL, that should not be used.另一个问题是 URL 中的“.git”,不应使用。

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 分支获取文件,但如果出现问题或有错别字,它将查找所有分支并抛出错误,提示未找到分支。

I was facing this same error recently and none of the above were working for me since I wanted Jenkins to checkout a specific branch of my code.我最近遇到了同样的错误,因为我希望 Jenkins 检出我的代码的特定分支,所以以上方法都不适合我。 The branch name was set to ${BRANCH} which was a Jenkins parameter I created on same job.分支名称设置为${BRANCH} ,这是我在同一作业中创建的 Jenkins 参数。

If I used some other branch, it worked fine.如果我使用其他一些分支,它工作正常。 Took me a long time to debug since it worked everywhere else.我花了很长时间进行调试,因为它在其他任何地方都有效。 I could clone the repo and checkout that branch myself locally without issues.我可以克隆 repo 并在本地签出该分支,而不会出现问题。 But only Jenkins seemed to be reporting this error.但似乎只有詹金斯报告了这个错误。

Finally after a lot of investigation, I realised the default value that I set to the BRANCH parameter in this Jenkins job was copied by me from an earlier run of the same job from the Parameters section.最后,经过大量调查,我意识到我在此 Jenkins 作业中为 BRANCH 参数设置的默认值是我从参数部分的同一作业的较早运行中复制的。 Looks like a hidden special character gets added if we copy from that section and that is why even though it looked to be the same branch I wanted to checkout in the Jenkins logs, it was somehow having an additional hidden character and hence was failing each time.如果我们从该部分复制,看起来会添加一个隐藏的特殊字符,这就是为什么即使它看起来是我想在 Jenkins 日志中检出的同一个分支,它不知何故有一个额外的隐藏字符,因此每次都失败. I deleted the default value from that parameter and re-typed that value as the default manually in the Job configuration and it worked fine after that.我从该参数中删除了默认值,并在作业配置中手动将该值重新键入为默认值,之后它工作正常。

Sometimes the branch name specified in the jenkins and repository are different.有时 jenkins 和存储库中指定的分支名称不同。 In my case jenkins set Master as a default branch in jenkins.就我而言,jenkins 将 Master 设置为 jenkins 中的默认分支。 But my actual branch is main.但我的实际分支是主要的。 Which costs me over two hours of my time to identify.这花费了我两个多小时的时间来识别。 I didn't change it as jenkins sets it default.我没有更改它,因为 jenkins 将其设置为默认值。 Errormain But it is the error. Errormain但它是错误。 So first verify the branch name in your repository and the branch name in jenkins if you get this error.因此,如果出现此错误,请首先验证存储库中的分支名称和 jenkins 中的分支名称。

On your Jenkins' job configuration, under the Pipeline SCM section, uncheck "Lightweight checkout" and Save.在 Jenkins 的作业配置中,在 Pipeline SCM 部分下,取消选中“Lightweight checkout”并保存。 Also make sure you name your branch correctly, as others have mentioned.还要确保您正确命名您的分支,正如其他人提到的那样。

I faced similar issue, the error was in the branch name , you'll need to specify the origin repository in the branch name to make sure changes are picked up.我面临着类似的问题,错误是在分支名称,你需要指定origin repositorybranch name ,以确保更改回升。

  • eg例如
origin/feature/branch_name

在 Jenkins 的 Branch Specifier 中留空对我有用 SourceCodeManagement>Branchs to build>Branch Specifier 它将默认为 */master 删除默认的

Question - ERROR: Couldn't find any revision to build.问题 - 错误:找不到任何要构建的修订版。 Verify the repository and branch configuration for this job.验证此作业的存储库和分支配置。 Hi Guys Kindly check the branch name that is targetting from jenkins build from It should be same both side(git and jenkins )嗨,伙计们,请检查从 jenkins 构建中定位的分支名称它应该是相同的(git 和 jenkins)

In my case I resolved the issue by updating Jenkins Default branch name from " /master" to " /Master".就我而言,我通过将 Jenkins 默认分支名称从“ /master”更新为“ /Master”来解决该问题。 I am using Bitbucket cloud and Master branch.我正在使用 Bitbucket 云和 Master 分支。

this worked for me:这对我有用:

stage ('Git Checkout') {
  steps {
      git branch: 'main', url: 'https://<token>@github.com/username/repoName.git'
     }
  }

I also waste some time finding a solution.我也浪费了一些时间来寻找解决方案。 After some time I understood branch names are different that's why it's not taking.一段时间后,我明白了分支名称不同,这就是它没有采用的原因。

The solution is in my repo is main and trying with the master.its the error解决方案是在我的 repo is main 中尝试使用 master.its 错误

在此处输入图片说明

Changed like here像这里一样改变

在此处输入图片说明

In my case, below two values were missing.就我而言,缺少以下两个值。 Inside Pipeline ==> Definition ==> SCM ==> Advanced ==>流水线内部 ==> 定义 ==> SCM ==> 高级 ==>

Name = origin名称 = 原产地

Refspec = +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/* Refspec = +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*

I was using ${ghprbActualCommit} In Branch Specifier (blank for 'any') field我在分支说明符('any' 为空白)字段中使用${ghprbActualCommit}

I specified Branch as main我将分支指定为主要

Branch as main分支为主

and git path added and solved the issue git path和 git 路径添加并解决了问题git 路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:找不到要构建的任何修订。 验证此作业的存储库和分支配置 - ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job 找不到任何修改版本。 验证此作业的存储库和分支配置。 完成:失败 - Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE 从 jenkins 构建 git 项目时,它显示一个错误,例如找不到要构建的任何修订 - While building a git project from jenkins it shows an error like couldn't find any revision to build Jenkins gerrit触发器找不到任何修改版本 - Jenkins gerrit trigger couldn't find any revision to build Jenkins 的 Gerrit 触发器找不到要构建的任何修订 - Gerrit trigger for Jenkins couldn't find any revision to build 在管道中运行作业时找到当前的git分支 - find current git branch while running job in pipeline git 存储库克隆失败。 连接重置 - git repository clone failed. Connection Reset 获取任何版本的git存储库中的文件数 - Get number of files in git repository at any revision 如何从詹金斯工作推到Git分支? - How to push to Git branch from Jenkins job? git push失败。 致命的:似乎不是git存储库 - git push failed. fatal: does not appear to be a git repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM