Cleaning the agent's working directory

Is there any functionality in place to automatically clean an agents working directory? An issue we are having is that we have many projects whose working directory can be quite large and in turn, because the agent does not automatically delete old build folders, we can run out of space on the agent, causing current builds to fail. Is there a way to configure the agent to clean up these old builds? Perhaps, to make sure that before starting a build there is a certain threshold of available space? Or, delete the build folder after completing a successful build? In our case, all of our builds start off clean so there is no need to keep the folders between builds.

Any suggestions before I write a script to do it?


Comment actions Permalink

By default directory lifetime is 8 idle days. It's possible to change this setting:
- by file with '' property
- by '' system property
Both those variables accept number of hours before build configuration is cleaned up.

idle day means there were no non-personal builds started on the agent on the day.

This option will only work if there is no build custom checkout directory.

Comment actions Permalink

Ok, I think the custom checkout directory may be the issue. Are you saying that if we define one, then no automated cleanup occurs? If that is the case, I really hope there is a workaround.

Comment actions Permalink

One workaround in this case is to create a build configuration which will remove all files from the checkout directory and start this build configuration with help of scheduling trigger.

Pavel Sher


Please sign in to leave a comment.