Git PullRequest工作失败.找不到任何修改版本.验证此作业的存储库和分支配置

Vla*_*ski 14 git github pull-request jenkins

昨天我的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.
Run Code Online (Sandbox Code Playgroud)

我已经进行了调查,发现在财产$ {sha1}中没有任何东西.当我粘贴一个绝对路径来拉取请求构建器,如pr/341/merge而不是$ {sha1}时,构建工作正常.它可以是什么?

Git客户端插件1.9.0

GitHub API插件1.44

Tam*_*tee 15

我花了很长时间在这上面.上面的评论"如果我把这个字段留空"就像一个魅力.在SCM中:
1)选择Git
2)名称:origin
3)Refspec:+refs/pull/*:refs/remotes/origin/pr/*
4)要构建的分支:留空

这解决了上述错误.

  • 上面的评论是“如果我将此字段留空”?有何评论?哪里? (4认同)
  • 请编辑您的答案并添加代码/命令格式以方便阅读。谢谢你。 (2认同)
  • ** 我在 Jenkins 中也遇到了同样的问题,我删除了要构建的分支名称,我的问题得到了解决 ** 我挣扎了两个多小时 (2认同)

Dul*_*ren 15

根据,Github上分支的默认名字已经从“主人”到“主”改变。

因此,在为新存储库创建新作业时,您必须将“main”设置为分支名称而不是“master”。

请注意,github 可以将“master”(或您方便的任何其他名称)设置为默认分支名称。

  • 完美的答案。这对我有用。谢谢。 (4认同)

小智 15

我也浪费了一些时间寻找解决方案。一段时间后,我了解到分支名称不同,这就是它不被采用的原因。

解决方案在我的存储库中是 main 并尝试使用 master.its 错误

在此输入图像描述

像这里一样改变

在此输入图像描述

  • 与我相同的错误找不到分支名称。 (2认同)

xia*_*lin 9

如前所述在这里,如果你想手动建设工作,在工作中设置检查此版本是参数和添加名为字符串参数sha1用的默认值master.在开始构建时,给出要构建或引用的sha1参数提交ID(例如:origin/pr/9/head).


son*_*nny 6

我通过使用refs/heads/<branchName>“Branches to build-branch specifier”中的语法修复了同样的错误消息。

例如,origin/master我将, 而不是,refs/remotes/origin/master作为分支说明符来修复工作。

(在我的情况下,我不确定是什么导致出现此错误消息,因为该作业以前与origin/master分支说明符一样正常工作。它可能是相关的更新或配置更改......)


请注意,您可以使用git show-ref命令列出本地存储库中的引用,例如

git show-ref master
28f1f186807d1316bf1c59631d6d8825a5087e27 refs/heads/master
28f1f186807d1316bf1c59631d6d8825a5087e27 refs/remotes/origin/master
Run Code Online (Sandbox Code Playgroud)

还有,“?” “分支说明符”字段旁边的帮助文档也支持将此答案作为指定分支说明符以确保预期分支明确无误的最安全选项:

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.
Run Code Online (Sandbox Code Playgroud)


Yog*_*ngh 5

您需要定义分支名称,因为 Jenkins 默认捕获 master,而 GitHub 中没有 master,它现在是 main,因此在 GitHub 的情况下,您还需要传递分支名称。

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

它解决了我的问题