Just came across this issue, since I am trying to cleanup the workspace with this code sequence:
sh 'find -mindepth 1 -maxdepth 1 \\! -name .git -exec rm {} +'
My intention is to clean everything but keep the .git directory. However, this fails, because it also tries to remove the temporary directory, which e.g. contains the script file that it is currently executing, like: ./.4cba202f/script.sh
Since the directory is arbitrary, there is no easy workaround.
I think a gradual improvement would be to give the directory at least consistent name or prefix, like .jenkins-tmp/4cba202f/.... This way it is possible to stay away from it.
|