报错日志:
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
之后问题解决.
进入容器指令:
docker exec -u root -it jenkins-agent /bin/bash
更改组和所有者指令:
chown jenkins:jenkins workspace/
PS: 我的workspace
目录做了持久化处理(挂载了docker volume
),所以进入容器修改一次之后就会一直生效。