What I am trying to accomplish - I want to have a wrapper for git itself, that will retry if the git command fails (timeout/network issue).
I have following dummy code of wrapper:
"C:\Program Files\Git\cmd\git.exe" %*
echo Success!
After changing $PATH and saving the file as git.cmd and removing path to git.exe it works well if I call any git command directly from jenkins:
script {
bat 'git clone %REPO%'
}
result:
(...)
Updating files: 100% (5314/5314), done.
17:58:51 E:\jenkins\workspace\sandbox>echo Success!
17:58:51 Success!
However I want it to work for multibranch pipeline, which uses jenkins git plugin https://github.com/jenkinsci/git-plugin/blob/master/README.adoc
And running checkout with this plugin results in:
18:48:46 Caused by: java.io.IOException: Cannot run program "git" (in directory "E:\jenkins\workspace\PR-XXXX"): CreateProcess error=2, The system cannot find the file specified
Somehow the git plugin knows, it is missing the git.exe and it is not picking up the git.cmd wrapper script as in the first example. Any suggestions, Guys?