【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
相关推荐
chen94519 分钟前
mysql 3节点mgr集群部署
运维·后端
LH_R1 小时前
OneTerm开源堡垒机实战(三):功能扩展与效率提升
运维·后端·安全
dessler2 小时前
Hadoop HDFS-高可用集群部署
linux·运维·hdfs
少妇的美梦20 小时前
logstash教程
运维
chen94520 小时前
k8s集群部署vector日志采集器
运维
chen94520 小时前
aws ec2部署harbor,使用s3存储
运维
東雪蓮☆1 天前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
qq_264220891 天前
LVS负载均衡群集和LVS+Keepalived群集
运维·负载均衡·lvs
乌萨奇也要立志学C++1 天前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
雨落Liy1 天前
Nginx 从入门到进阶:反向代理、负载均衡与高性能实战指南
运维·nginx·负载均衡