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)要构建的分支:留空
这解决了上述错误.
小智 15
我也浪费了一些时间寻找解决方案。一段时间后,我了解到分支名称不同,这就是它不被采用的原因。
解决方案在我的存储库中是 main 并尝试使用 master.its 错误
像这里一样改变
我通过使用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)
您需要定义分支名称,因为 Jenkins 默认捕获 master,而 GitHub 中没有 master,它现在是 main,因此在 GitHub 的情况下,您还需要传递分支名称。
git branch: 'main', credentialsId: 'GithubCred', url: 'Your-Repo-URL'
它解决了我的问题