Clean Jenkins Workspace
Cleaning a workspace is an important housekeeping activity for your pipelines because we rarely overprovision storage so there is usually only enough space on an agent for a few builds. If the intention is that you want to resuse agents then we advise you to perform some housekeeping activities in your pipelines. To do this we leverage the post function in the Jenkins pipeline to execute tasks at the end of a pipeline. The post pipeline supports properties to enable you to run various activities based on the success of the pipeline.
Clean Workspace
post {
always {
deleteDir()
}
}
Updated on: 01/11/2025
Thank you!