Jenkins cannot delete workspace

Viewed 6467

I have been struggling with this common problem, yet cannot find a good solution. I have a java process that creates a handle to a file located in the workspace, and so the next build fails not being able to delete the workspace. The slave machine is a Windows machine. I am looking for a way to force delete the workspace regardless of the running processes, and I would like that to happen in the begining of the build. Does anyone know how to do that properly? In a freestyle job? Thank you!

1 Answers

Jenkins Post Build Action > 'Delete Workspace when the build is done' should do the job.
Or else, if you have permission problems, then you can
Add a Build Step > 'Execute shell'
and run command 'sudo rm -rf $WORKSPACE'

Related