jenkinsci/jenkins — pull request #1209 by pjdarton (2014-04-22 12:57:35+00:00)
Title: Fix for JENKINS-15331

This changes Jenkins' strategy when doing recursive deletes so that it no longer stops iterating through a directory when it finds a file it can't delete - it'll try to delete what it can before throwing the exception.
It also changes the default number of attempts that Jenkins makes when doing a recursive delete from 2 attempts to 3 attempts.
This combination results in a dramatic improvement in deletion reliability on Windows-based job executors.

Lastly, this behavior is now configurable (on a per-JVM basis), albeit crudely - like the existing hudson.Util.noSymlink & hudson.Util.symlinkEscapeHatch flags, these can be configured using -D options when starting the Jenkins or slave services.

-Dhudson.Util.deletionRetries=3
Sets the number of times Jenkins will try to delete a file before giving up.
Defaults to 3 attempts.

-Dhudson.Util.deletionRetryWait=100
Sets the time (in milliseconds) for which Jenkins will pause between delete attempts.
Defaults to 100ms between each attempt.
If set to a negative number, it will delay for a linearly increasing amount between attempts.

-Dhudson.Util.performGCOnFailedDelete=false
If set to true, this tells Jenkins to run the Garbage Collector between attempts (just in case the process holding a file open is an un-garbage-collected Java filehandle within Jenkins itself).
It defaults to false.

(Note: This was reworked to patch the Jenkins master branch as of 12:30 GMT April 22 2014, and superceeds pull request 1183)