首页 > 解决方案 > 使用 deleteDir 的 Jenkins 管道“无法删除”

问题描述

我有一个詹金斯管道,post最后有一个电话。看起来像这样:

post {
    always {
        deleteDir()
    }
}

这是日志:

[Pipeline] { (Declarative: Post Actions)
[Pipeline] deleteDir
Error when executing always post condition:
java.io.IOException: Unable to delete '/var/jenkins_home/workspace/abide/.git/logs/refs/heads/master'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
    at hudson.Util.deleteFile(Util.java:277)
    at hudson.FilePath.deleteRecursive(FilePath.java:1322)
    at hudson.FilePath.deleteContentsRecursive(FilePath.java:1331)
    at hudson.FilePath.deleteRecursive(FilePath.java:1313)
    at hudson.FilePath.deleteContentsRecursive(FilePath.java:1331)
    at hudson.FilePath.deleteRecursive(FilePath.java:1313)
    at hudson.FilePath.deleteContentsRecursive(FilePath.java:1331)
    at hudson.FilePath.deleteRecursive(FilePath.java:1313)
    at hudson.FilePath.deleteContentsRecursive(FilePath.java:1331)
    at hudson.FilePath.deleteRecursive(FilePath.java:1313)
    at hudson.FilePath.deleteContentsRecursive(FilePath.java:1331)
    at hudson.FilePath.deleteRecursive(FilePath.java:1313)
    at hudson.FilePath.access$1600(FilePath.java:209)
    at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1291)
    at hudson.FilePath$DeleteRecursive.invoke(FilePath.java:1287)
    at hudson.FilePath.act(FilePath.java:1095)
    at hudson.FilePath.act(FilePath.java:1078)
    at hudson.FilePath.deleteRecursive(FilePath.java:1285)
    at org.jenkinsci.plugins.workflow.steps.DeleteDirStep$Execution.run(DeleteDirStep.java:77)
    at org.jenkinsci.plugins.workflow.steps.DeleteDirStep$Execution.run(DeleteDirStep.java:69)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:49)
    at hudson.security.ACL.impersonate(ACL.java:290)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:46)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.nio.file.FileSystemException: /var/jenkins_home/workspace/abide/.git/logs/refs/heads/master: Operation not permitted
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileAttributeViews$Posix.setMode(UnixFileAttributeViews.java:238)
    at sun.nio.fs.UnixFileAttributeViews$Posix.setPermissions(UnixFileAttributeViews.java:260)
    at java.nio.file.Files.setPosixFilePermissions(Files.java:2045)
    at hudson.Util.makeWritable(Util.java:337)
    at hudson.Util.tryOnceDeleteFile(Util.java:297)
    at hudson.Util.deleteFile(Util.java:272)
    ... 27 more

[Pipeline] }
[Pipeline] // stage
[Pipeline] }

我在这里找到了这篇文章,没有人有解决方案,而且它错过了错误,所以我重新发布。

标签: jenkinsjenkins-pipeline

解决方案


推荐阅读