-
Bug
-
Resolution: Fixed
-
Major
-
None
We're executing a job, and trying to perform a git clean. One of our submodules is dirty, and unfortunately since the Jenkins GIT plugin cleans after checkout, we get the following error:
FATAL: Command "git submodule update --init --recursive" returned status code 1:
stdout:
stderr: error: Your local changes to the following files would be overwritten by checkout:
minified/sidecar.js
minified/sidecar.lite.js
minified/sidecar.lite.min.js
minified/sidecar.min.js
Please, commit your changes or stash them before you can switch branches.
Aborting
Unable to checkout 'd58c3304230e4bf26ffb3fa6986d4b6ba90d4c66' in submodule path 'sugarcrm/sidecar'
I tested using the Pre-SCM Buildstep plugin and performing a git clean before the checkout fixes the problem. Specifically having it perform:
git submodule foreach --recursive git clean -fdx
git submodule foreach --recursive git reset --hard
before we do the checkout fixes it.
- is related to
-
JENKINS-8503 Git submodules are cloned too early and not removed once the revToBuild has been checked out
-
- Open
-
-
JENKINS-7376 git - clean before build does not clean submodules
-
- Closed
-
-
JENKINS-7445 Git doesn't clean and update submodules correctly
-
- Closed
-
-
JENKINS-8315 clean should be run before submodule update
-
- Closed
-
-
JENKINS-13910 git plugin: 'clean after checkout" does not git clean -fdx on submodules
-
- Closed
-
Mark, I appreciate your willingness to help us out here. TBH, I don't feel that my situation is unique to submodules. It appears to me that the problem would arise anytime that you have a conflict of a file between what you have in your working copy, and what your trying to checkout. I'd love to be able to add some tests around this, but have been quite busy at work in other regards lately. My 2 cents are, do we really need clean after checkout? Is there any situation that this behavior is needed, that can't be taken care of by doing a clean before checkout? Perhaps we should change Clean After Checkout to be called Clean Before Checkout, and change its behavior to do what we implemented in clean before checkout? What do you think? I'm more than happy to have David or I help out here.
I should mention, what worked for us was the correct order of operations. We didn't need a git clean -ffdx, we just needed git clean -fdx and git reset --hard to be executed on all submodules BEFORE we do a checkout on those submodules.