【Jenkins】新建任务FAQ

问题1. 源码管理处填入Repository URL,报错:无法连接仓库:Error performing git command: ls-remote -h https://github.com/txy2023/GolangLearning.git HEAD


原因:

jenkins全局工具配置里默认没有添加git的路径,如果你是centos系统,可以which git获取git路径。然后从Dashboard依次点击系统管理-全局工具配置,在Path to Git executable填入git路径

问题2. 构建任务,控制台报错: ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.


原因:

拉取的分支不对,git项目默认分支一般是main,而jenkins默认拉取分支是master,因此在源码管理处修改指定分支即可

修改后,再次构建,成功拉取git项目,默认保存路径为/var/lib/jenkins/workspace/xxx

问题3. 源码管理处填入Repository URL,报错:stderr: Host key verification failed. fatal: Could not read from remote repository.


原因:

  1. github上没有添加SSH key
  2. github上添加的SSH key不对,jenkins拉取源码时默认使用的是jenkins用户
    具体方法:
  • 切换到jenkins用户,生成ssh公钥
bash 复制代码
 su -s /bin/sh jenkins
 ssh-keygen
  • 根据生成的id_rsa.pub文件,在github上重新添加SSH Key
  • 最重要的一步 ,在jenkins用户下,手动执行一次Command/usr/bin/git ls-remote -h git@github.com:txy2023/GolangLearning.git HEAD(根据报错页面上实际的Command执行),目的是自动生成~/.ssh/known_hosts
相关推荐
小草cys4 小时前
在 openEuler 上安装 DDE 图形桌面环境(适用于华为鲲鹏服务器/PC)
运维·服务器
天才奇男子11 小时前
HAProxy高级功能全解析
linux·运维·服务器·微服务·云原生
小李独爱秋11 小时前
“bootmgr is compressed”错误:根源、笔记本与台式机差异化解决方案深度指南
运维·stm32·单片机·嵌入式硬件·文件系统·电脑故障
Dying.Light12 小时前
Linux部署问题
linux·运维·服务器
S190112 小时前
Linux的常用指令
linux·运维·服务器
萤丰信息12 小时前
AI 筑基・生态共荣:智慧园区的价值重构与未来新途
大数据·运维·人工智能·科技·智慧城市·智慧园区
小义_13 小时前
【RH134知识点问答题】第7章 管理基本存储
linux·运维·服务器
运维小欣13 小时前
Agentic AI 与 Agentic Ops 驱动,智能运维迈向新高度
运维·人工智能
_运维那些事儿14 小时前
VM环境的CI/CD
linux·运维·网络·阿里云·ci/cd·docker·云计算
Trouvaille ~15 小时前
【Linux】UDP Socket编程实战(一):Echo Server从零到一
linux·运维·服务器·网络·c++·websocket·udp