Jenkins Pipeline Wipe Out Workspace

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

    I used deleteDir() as follows:

      post {
            always {
                deleteDir() /* clean up our workspace */
            }
        }
    

    However, I then had to also run a Success or Failure AFTER always but you cannot order the post conditions. The current order is always, changed, aborted, failure, success and then unstable.

    However, there is a very useful post condition, cleanup which always runs last, see https://jenkins.io/doc/book/pipeline/syntax/

    So in the end my post was as follows :

    post {
        always {
    
        }
        success{
    
        }
        failure {
    
        }
        cleanup{
            deleteDir()
        }
    }
    

    Hopefully this may be helpful for some corner cases

提交回复
热议问题