The second time 'force clean and sync' is run on a Windows slave it fails because it cannot delete the files it synced as read only (default workspace behavior) during the last build. Error seen in console logs is:
(1) Start a windows slave. For example using the following batch file:
(2) Create a freestyle job that does a 'Force clean and sync'.
(3) Execute the job. All files are synced to the workspace as read-only.
(4) Execute the job a seconds time. Job fails during the rm -rf command:
When you check the workspace, no files have been deleted.
Windows process moitor showed that it failed trying to delete a synced file that is not open by any other process:
Note - When 'delete workspace before build starts' is used the same call works but the files have been moved???
If you manually go onto the build node and remove the 'Read Only' flag agsinst the synced files it works.
If you always use the 'allwrite' client option on the Perforce workspace used it also works.
If you choose the the Jenkins option 'Delete workspace before build starts' it works.
Therefore the Jenkins slave has permission to remove the files, it's just the P4-Plugin that cannot.