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:
stderr: error: Your local changes to the following files would be overwritten by checkout:
Please, commit your changes or stash them before you can switch branches.
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.