I have my Jenkins build configured to "Clean before Checkout" for its git source:
Job Config > Source > git > Behaviours > Clean before checkout
This results in
Resetting working tree
git reset --hard # timeout=10
git clean -fdx # timeout=10
Before the job begins.
This errors out with
stderr: warning: failed to remove web/static/node_modules/.../fonts/google-fonts: Directory not empty
If I re-run the job (simply replay), I get the same error.
If I re-run it again, git clean works fine and the job finishes with success in the end.
If I start it again it errors out 2 times again until it works at the third time. This is always the case.
What might be going on here?
git clean
executes, they may keep file descriptors open or create new files in the directory tree being removed, preventing removal. Even a regular shell with thecwd
set somewhere within that tree can cause that.