本文介绍了Jenkins管道-删除@tmp文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作业完成后,我正在使用工作区清理插件"来清理工作区.但是@tmp目录仍未删除.

I am using "Workspace Cleanup Plugin" to clean workspace after the job finishes. But still @tmp directory is not deleted.

我们可以使用管道脚本删除此@tmp文件夹.

Any way we can delete this @tmp folder using pipeline script.

就我在Ji​​ra中所见,这似乎是一个已知问题:

It looks like a known issue as far as I see in Jira:

  • https://issues.jenkins-ci.org/browse/JENKINS-44909
  • https://issues.jenkins-ci.org/browse/JENKINS-41805

推荐答案

我在Jenkins中使用了自定义工作区,然后deleteDir()不会删除@tmp文件夹.

I used custom workspace in Jenkins then deleteDir() will not delete @tmp folder.

因此要删除@tmp以及工作区,请使用以下

So to delete @tmp along with workspace use following

pipeline {
    agent {
        node {
            customWorkspace "/home/jenkins/jenkins_workspace/${JOB_NAME}_${BUILD_NUMBER}"
        }
    }
    post {
        cleanup {
            /* clean up our workspace */
            deleteDir()
            /* clean up tmp directory */
            dir("${workspace}@tmp") {
                deleteDir()
            }
            /* clean up script directory */
            dir("${workspace}@script") {
                deleteDir()
            }
        }
    }
}

此代码段也适用于默认工作空间.

这篇关于Jenkins管道-删除@tmp文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 14:46