Jenkins Pipeline Wipe Out Workspace

前端 未结 13 1436
你的背包
你的背包 2020-12-04 08:59

We are running Jenkins 2.x and love the new Pipeline plugin. However, with so many branches in a repository, disk space fills up quickly.

Is there any plugin that

13条回答
  •  伪装坚强ぢ
    2020-12-04 09:38

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

    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()
                }
            }
        }
    }
    

    This snippet will work for default workspace also.

提交回复
热议问题