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
相关推荐
念念不忘 必有回响44 分钟前
前端自动化部署全流程(Jenkins + Nginx)
前端·自动化·jenkins
不 再 熬 夜1 小时前
Docker搭建Jenkins
docker·jenkins
tingting011918 小时前
jenkins在使用中遇到的问题
运维·jenkins
一张假钞1 天前
Windows下Jenkins服务未自动重启问题解决
jenkins
Narutolxy1 天前
从混合部署到高可用:在内网环境下搭建 GitLab-Jenkins-OpenResty的完整实战复盘20251014
gitlab·jenkins·openresty
一张假钞1 天前
Ubuntu 24.04 安装 Jenkins
linux·ci/cd·jenkins
getExpectObject()1 天前
【jenkins】构建安卓
运维·jenkins
会写代码的饭桶2 天前
Jenkins 实现 Vue 项目自动化构建与远程服务器部署
vue.js·自动化·jenkins
qinxue7222 天前
Jenkins自动化配置--CICD流水线
运维·自动化·jenkins
一念一花一世界2 天前
开源CICD工具深度横评,Jenkins vs Arbess哪个更适合你?
jenkins·arbess·tiklab devops·cicd工具