【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),所以进入容器修改一次之后就会一直生效。

相关推荐
御前一品带刀侍卫6 小时前
elasticsearch基础
大数据·elasticsearch·搜索引擎
武子康7 小时前
大数据-191 Elasticsearch - ES 集群模式 配置启动 规划调优
java·大数据·elk·elasticsearch·搜索引擎·全文检索
落落落sss7 小时前
es实现自动补全
大数据·服务器·elasticsearch·搜索引擎·全文检索
小汤猿人类7 小时前
什么是Elasticsearch?
大数据·elasticsearch·搜索引擎
武子康7 小时前
大数据-187 Elasticsearch - ELK 家族 Logstash Filter 插件 使用详解
大数据·数据结构·elk·elasticsearch·搜索引擎·全文检索·1024程序员节
JavaOpsPro7 小时前
jenkins部署手册
运维·jenkins·离线部署
搬砖天才、8 小时前
自动化部署-02-jenkins部署微服务
微服务·自动化·jenkins
执键行天涯9 小时前
【工具使用】VSCode如何将本地项目关联到远程的仓库 (vscode本地新项目与远程仓库建立链接)
ide·vscode·elasticsearch
尘佑不尘12 小时前
shodan5,参数使用,批量查找Mongodb未授权登录,jenkins批量挖掘
数据库·笔记·mongodb·web安全·jenkins·1024程序员节
再拼一次吧13 小时前
Elasticsearch
大数据·elasticsearch·搜索引擎