我的Jenkins服务器上安装了Git和Git Pull Request Builder插件,并且我在GitHub上创建了Web挂钩,以便在以下情况下自动触发我的构建:(1)打开一个pull请求或者(2)从某人的分支到主存储库发生合并。
我在执行MERGE构建时遇到间歇性问题(上面的方案2),Git会抛出此异常:
FATAL: Could not checkout d68a985c98badf605b12b63424beb08776ab2752
hudson.plugins.git.GitException: Could not checkout d68a985c98badf605b12b63424beb08776ab2752
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$8.execute(CliGitAPIImpl.java:1907)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1060)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1275)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "git checkout -f d68a985c98badf605b12b63424beb08776ab2752" returned status code 128:
stdout:
stderr: fatal: reference is not a tree: d68a985c98badf605b12b63424beb08776ab2752
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1640)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:62)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$8.execute(CliGitAPIImpl.java:1899)
... 10 more
有问题的提交(d68a985c98badf605b12b63424beb08776ab2752)实际上是来自某个尚未合并到主存储库的某个fork的请求,所以为什么Git尝试在执行构建在我的主存储库的人员分支的主分支上。
我用于在主存储库上构建主分支的refspec是:
+refs/heads/master:refs/remotes/origin/master
这个真的让我目瞪口呆,而且我也不知道从哪里开始。我看到类似的问题,例如https://github.com/travis-ci/travis-ci/issues/617,但如果它们相关则对我来说并不明显。
非常感谢任何帮助!