Pipeline流水线通过git拉取Jenkinsfile报错 error: RPC failed; result=22, HTTP code = 404

Pipeline流水线通过git拉取Jenkinsfile报错 error: RPC failed; result=22, HTTP code = 404

在学习共享库时使用通过git拉取jenkinsfile时,报错在排查gitlab服务状态,网络通讯,防火墙规则以及Jenkins凭据均可以正常使用,最后发现的时在URL填写中缺少 .git 结尾所导致的,在了解后得知在 GitLab 或 GitHub 中,通常使用仓库 URL 来拉取代码,例如:

http://12.12.1.171/root/pipeline.git

这个 URL 后缀的 .git 对 Git 来说是必要的,尤其是当服务器需要识别它是一个 Git 仓库时。这有以下几个原因:

  1. 服务器路径解析:带 .git 后缀的 URL 通常用于指示服务器该路径是一个 Git 仓库。如果缺少 .git,服务器可能无法正确处理这个请求,从而导致 404 错误,因为它可能将其解释为常规网页请求,而不是一个仓库拉取请求。
  2. 标准规范:虽然在某些情况下,Git 服务器可能会容忍省略 .git,但为了兼容性和确保正确性,建议始终使用 .git 后缀。

所以,少写 .git 后缀会导致 Jenkins 或其他 Git 客户端在尝试从服务器获取仓库时找不到该路径,从而报错。在 Repository URL 字段中补充 .git 来解决这个问题。

Started by user jenkins管理员
hudson.plugins.git.GitException: Command "git fetch --tags --progress --prune origin +refs/heads/master:refs/remotes/origin/master" returned status code 128:
stdout: 
stderr: error: RPC failed; result=22, HTTP code = 404
fatal: The remote end hung up unexpectedly

	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2846)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
	at PluginClassLoader for git//jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:406)
	at PluginClassLoader for scm-api//jenkins.scm.api.SCMFileSyst
	em.of(SCMFileSystem.java:219)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:126)
	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:73)
	at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:311)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:446)
Finished: FAILURE

image-20240908181628563

image-20240908182021268

image-20240908182314042

posted @ 2024-09-08 18:26  xiao智  阅读(50)  评论(0编辑  收藏  举报