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 复制代码
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 来解决这个问题。

shell 复制代码
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
相关推荐
要站在顶端3 小时前
Jenkins PR编号提取&环境变量赋值问题总结
java·servlet·jenkins
DN金猿4 小时前
jenkins 权限控制(用户只能看指定的项目)
linux·运维·服务器·jenkins
weixin_307779134 小时前
Jenkins Pipeline: Basic Steps 插件详解
开发语言·ci/cd·自动化·jenkins·etl
java_logo5 小时前
AdguardHome Docker 容器化部署指南
运维·docker·容器·jenkins·adguardhome·部署adguardhome·docker adguard
weixin_307779135 小时前
Jenkins Pipeline:Groovy插件全解析:从原理到实战应用
开发语言·ci/cd·自动化·jenkins·etl
weixin_307779135 小时前
Jenkins Pipeline: API 插件详解
运维·ci/cd·自动化·jenkins·etl
weixin_307779136 小时前
Jenkins Declarative Pipeline:现代CI/CD的声明式实践指南
开发语言·ci/cd·自动化·jenkins·etl
weixin_307779131 天前
Jenkins Token Macro 插件:宏扩展的基石
开发语言·ci/cd·架构·自动化·jenkins
weixin_307779131 天前
Jenkins SSH Build Agents 插件详解:远程构建的利器
运维·开发语言·架构·ssh·jenkins
靈龍靈1 天前
ELBK部署
运维·ci/cd·jenkins