-
Bug
-
Resolution: Won't Do
-
Minor
-
Jenkins BlueOcean 2.190.2
git 4.0.0
TL;DR:
git clean -fdx should be git clean -ffdx as per this advice
Problem / Steps To Reproduce
If a build creates a git repository in a subdirectory of the workspace, the option to "clean after checkout" will skip it. This is expected behavior of git that you can verify quite easily:
# assuming we are ubuntu@jenkins-agent:/tmp/jenkins-blah/workspace/some-job some-job$ mkdir foo some-job$ cd foo some-job/foo$ git init Initialized empty Git repository in /tmp/jenkins-blah/workspace/some-job/foo/.git/ some-job/foo$ cd .. some-job$ git clean -fdx Skipping repository foo/ some-job$ git clean -ffdx Removing foo/
Expected behavior
Git plugin cleans the workspace by removing the foo directory that has been initialized with its own git repository
some-job$ git clean -ffdx Removing foo/
Actual behavior
Git plugin silently fails to clean the workspace because the git command it runs succeeds with a warning message that the directory containing another repository was skipped:
some-job$ git clean -fdx Skipping repository foo/
Suggested fix
Use the -f option twice with git: git -ffdx to force removal of directories that contain git repositories.
Possible problems with git -ffdx
I'm not sure whether simply making this change will affect subdirectories; it shouldn't, but I haven't tested.
Issues that are NOT this issue:
JENKINS-21369(because my git clean command succeeds)- JENKINS-23694 (because that's about submodules that are expected)
- is related to
-
JENKINS-26660 Add another '-f' to git clean to remove deleted submodules or other repos checked out in workspace in pipeline
- Closed
-
JENKINS-45705 Git clean before or after checkout should call git clean -ffdx (2 "f"s)
- Closed
-
JENKINS-29893 Allow exclusions for git clean
- Closed