【Jenkins】解决使用容器化部署的Jenkins Agent节点时出现的git检查报错

报错日志:

bash 复制代码
Running on agent-0.230 in /home/jenkins/workspace/pipeline-test
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout from GitLab)
[Pipeline] git
ERROR: Checkout failed
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 192.168.0.230/192.168.0.230:45106
		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1826)
		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
		at hudson.remoting.Channel.call(Channel.java:1042)
		at hudson.FilePath.act(FilePath.java:1229)
		at hudson.FilePath.act(FilePath.java:1218)
		at hudson.FilePath.mkdirs(FilePath.java:1409)
		at PluginClassLoader for git//hudson.plugins.git.GitSCM.createClient(GitSCM.java:843)
		at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1299)
		at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1277)
		at PluginClassLoader for workflow-scm-step//org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136)
		at PluginClassLoader for workflow-scm-step//org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:101)
		at PluginClassLoader for workflow-scm-step//org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:88)
		at PluginClassLoader for workflow-step-api//org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
		at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
		at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.nio.file.AccessDeniedException: /home/jenkins/workspace/pipeline-test
	at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(Unknown Source)
	at java.base/java.nio.file.Files.createDirectory(Unknown Source)
	at java.base/java.nio.file.Files.createAndCheckIsDirectory(Unknown Source)
	at java.base/java.nio.file.Files.createDirectories(Unknown Source)
	at Jenkins v2.462.2//hudson.FilePath.mkdirs(FilePath.java:3753)
	at Jenkins v2.462.2//hudson.FilePath$Mkdirs.invoke(FilePath.java:1419)
	at Jenkins v2.462.2//hudson.FilePath$Mkdirs.invoke(FilePath.java:1414)
	at Jenkins v2.462.2//hudson.FilePath$FileCallableWrapper.call(FilePath.java:3615)
	at hudson.remoting.UserRequest.perform(UserRequest.java:225)
	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
	at hudson.remoting.Request$2.run(Request.java:391)
	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:81)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:140)
	at java.base/java.lang.Thread.run(Unknown Source)
ERROR: Maximum checkout retry attempts reached, aborting

解决方案:

根据日志内容可以看出是在执行mkdir创建目录时没有权限导致的。

进入容器检查/jenkins/workspace的权限和所有者时确实发现情况不太对,更改所有者和组为jenkins:jenkins之后问题解决.

进入容器指令:

bash 复制代码
docker exec -u root -it jenkins-agent /bin/bash

更改组和所有者指令:

bash 复制代码
chown jenkins:jenkins workspace/

PS: 我的workspace目录做了持久化处理(挂载了docker volume),所以进入容器修改一次之后就会一直生效。

相关推荐
Smile丶凉轩30 分钟前
微服务即时通讯系统的实现(服务端)----(1)
c++·git·微服务·github
jwolf22 小时前
Elasticsearch向量搜索:从语义搜索到图搜图只有一步之遥
elasticsearch·搜索引擎·ai
你可以叫我仔哥呀3 小时前
ElasticSearch学习笔记三:基础操作(一)
笔记·学习·elasticsearch
hummhumm3 小时前
第 25 章 - Golang 项目结构
java·开发语言·前端·后端·python·elasticsearch·golang
牙牙7056 小时前
Centos7安装Jenkins脚本一键部署
java·servlet·jenkins
灼烧的疯狂7 小时前
K8S + Jenkins 做CICD
容器·kubernetes·jenkins
java1234_小锋7 小时前
Elasticsearch中的节点(比如共20个),其中的10个选了一个master,另外10个选了另一个master,怎么办?
大数据·elasticsearch·jenkins
Elastic 中国社区官方博客7 小时前
Elasticsearch 开放推理 API 增加了对 IBM watsonx.ai Slate 嵌入模型的支持
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
我的运维人生7 小时前
Elasticsearch实战应用:构建高效搜索与分析平台
大数据·elasticsearch·jenkins·运维开发·技术共享
运维老司机7 小时前
Jenkins修改LOGO
运维·自动化·jenkins