clonejgitwindows-task-scheduler

JGit Clone Repo kicked off from windows task manager fails


Lets start by saying my code works. I can click a batch file that runs a jar file, that downloads some code from GIT.

Git gitRepo = Git.cloneRepository().setURI( remoteProjectPath )
.setDirectory(new File(destination))
.setCredentialsProvider( new UsernamePasswordCredentialsProvider( repoUser, repoPassword ) )
.setBranch(branch)
.setNoCheckout(true)
.call();

In windows, in my user profile folder i have a .gitconfig file that contains:

[http]
sslverify = false

when I double click the batch file, it works. But, this is part of an automated process. i need windows task scheduler to execute the batch file at midnight. (time is not important, other than it's when i'm not at work.) But i can open the task scheduler and click on the task and click 'run' and it fails with the sslverify flag.

"Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

it appears to me that the .gitconfig is only used when I (manually) execute the process. Is there a way to figure out if JGit is attempting to read from a different dir when started by task scheduler? Or is there another way to make JGit use sslverify=false for a sparse checkout using CloneCommand?


Solution

  • In a reference to EGit I found: How to change "Location" for "User Settings"

    I went to the system environment variables and created a system variable 'HOME' and set it to a directory containing the .gitconfig file I needed, and now the process works even when kicked off from Windows task scheduler.