jenkins+gitlab配置遇到问题

在尝试搭建Jenkins+GitLab自动化部署时,遇到了拉取代码失败的问题。根据日志,已将公钥和私钥配置到jenkins服务器的~/.ssh目录,并尝试将公钥添加到known_hosts或authorized_keys文件中。同时,在Jenkins凭证中配置了使用jenkins启动账号和~/.ssh/id_rsa私钥。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

搭建jenkins+gitlab拉取代码失败,日志如下:

ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@gitlab.bbtree.com:magw/crm_api_auto.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:862)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1129)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1160)
	at hudson.scm.SCM.checkout(SCM.java:495)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1202)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
	at hudson.model.Run.execute(Run.java:1724)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:421)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@gitlab.bbtree.com:magw/crm_api_auto.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: Host key verification failed.
fatal: Could not read from remote repository.
  1. 把配置好的公钥、私钥拷贝到jenkins服务器的~/.ssh目录下
  2. 把公钥拷贝到.ssh known_hosts或者authorized_keys(不一定有效,但是解决问题中操作了这一步骤)
  3. 配置jenkins credential,username为jenkins的启动账号,私钥目录选择~/.ssh/id_rsa
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值