Jenkins Pipeline Wipe Out Workspace

前端 未结 13 1426
你的背包
你的背包 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:55

    The mentioned solutions deleteDir() and cleanWs() (if using the workspace cleanup plugin) both work, but the recommendation to use it in an extra build step is usually not the desired solution. If the build fails and the pipeline is aborted, this cleanup-stage is never reached and therefore the workspace is not cleaned on failed builds.

    => In most cases you should probably put it in a post-built-step condition like always:

    pipeline {
        agent any
        stages {
            stage('Example') {
                steps {
                    echo 'Hello World'
                }
            }
        }
        post { 
            always { 
                cleanWs()
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题