You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins连接GitHub失败求助:无法克隆指定仓库

Jenkins连接GitHub仓库克隆失败问题排查

问题概述

作为Jenkins新手,尝试连接GitHub仓库https://github.com/Emanuel-Afro/Marvin-IT-Services.git并克隆时失败,返回状态码1,错误日志如下:

Failed to connect to repository : Command "/opt/java/openjdk/bin/Git-2.43.0-64-bit.exe ls-remote -h https://github.com/Emanuel-Afro/Marvin-IT-Services.git HEAD" returned status code 1:
stdout:
stderr: <3>WSL (197) ERROR: UtilGetPpid:1293: Failed to parse: /proc/1/stat, content: 1 (tini) S 0 1 1 0 -1 1077936384 504 0 0 0 4 49 0 0 20 0 1 0 83261540 2531328 222 18446744073709551615 94412274446336 94412274453789 140736124239408 0 0 0 0 3145728 0 1 0 0 17 2 0 0 0 0 0 94412274465552 94412274467979 94412278300672 140736124247472 140736124247515 140736124247515 140736124248042 0

目标:实现Jenkins服务器成功连接并克隆上述GitHub仓库。

解决方案

1. 修正Git路径配置

错误中调用的/opt/java/openjdk/bin/Git-2.43.0-64-bit.exe是Windows格式的可执行文件,与WSL环境冲突:

  • 进入Jenkins「全局工具配置」,找到Git的安装路径设置。
  • 若Jenkins运行在WSL环境,配置Linux版Git路径(如/usr/bin/git);若在Windows环境,配置本地Git的exe路径(如C:\Program Files\Git\bin\git.exe),确保路径正确且Jenkins有权限访问。

2. 解决WSL与Windows的Git环境冲突

若WSL中运行Jenkins但误调用了Windows Git:

  • 在WSL终端安装Linux版Git:
    sudo apt update && sudo apt install git
    
  • 验证安装:执行git --version,确认输出Linux版本信息。
  • 在Jenkins中重新配置Git路径为WSL内的可执行文件路径。

3. 验证仓库访问权限

  • 在Jenkins所在环境(WSL/Windows)手动执行测试命令:
    git ls-remote -h https://github.com/Emanuel-Afro/Marvin-IT-Services.git HEAD
    
  • 若提示权限问题,切换为SSH连接方式:
    1. 在Jenkins服务器生成SSH密钥对:ssh-keygen -t ed25519 -C "jenkins@your-server"
    2. 将公钥添加到GitHub仓库的「Deploy keys」中(仓库Settings → Deploy keys → Add deploy key)
    3. 在Jenkins中修改仓库地址为SSH格式:git@github.com:Emanuel-Afro/Marvin-IT-Services.git

4. 修复WSL进程解析异常

错误日志中的UtilGetPpid:1293提示WSL进程异常,尝试:

  • 在Windows命令行执行wsl --shutdown,重启WSL服务。
  • 更新WSL版本:执行wsl --update,确保WSL处于最新状态。

内容的提问来源于stack exchange,提问作者Amanuel Mulugeta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 06:32:33