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
相关推荐
新兴AI民工4 小时前
windows上的visual studio2022的项目使用jenkins自动打包
windows·jenkins·visual studio
风早君6 小时前
jenkins集成gitlab发布到远程服务器
服务器·gitlab·jenkins
Thanks_ks6 小时前
SpringBoot 自动化部署实战:CI/CD 整合方案与避坑指南
pipeline·jenkins·springboot·自动化部署·gitlab ci/cd·ci/cd 实战·docker 容器化
爱宇阳6 小时前
使用 Docker Compose 部署 Jenkins(LTS 版)持续集成环境
ci/cd·docker·jenkins
π大星星️11 小时前
Jenkins 工作流程
运维·jenkins
一介草民丶1 天前
Jenkins | Jenkins构建成功服务进程关闭问题
运维·servlet·jenkins
小黄人软件1 天前
jenkins脚本查看及备份
运维·servlet·jenkins
一介草民丶1 天前
Jenkins | Linux环境部署Jenkins与部署java项目
java·linux·jenkins
头疼的程序员2 天前
Jenkins的学习与使用(CI/CD)
ci/cd·jenkins
我科绝伦(Huanhuan Zhou)2 天前
保姆级Elasticsearch集群部署指导
大数据·elasticsearch·jenkins