开发者

Windows scheduled task to git push to github

开发者 https://www.devze.com 2023-03-22 01:05 出处:网络
I hope to add a Windows Scheduled Task to git push to github every night.I have a CMD file.When I run the CMD file on the windows command prompt, it works fine.But when I run it via windows scheduled

I hope to add a Windows Scheduled Task to git push to github every night. I have a CMD file. When I run the CMD file on the windows command prompt, it works fine. But when I run it via windows scheduled task. It's stuck forever. The status is "running". And from the log I can see it successfully started the git bash shell. Any idea?

echo git push > i:\gitpush
echo 'pushing' >>log1
C:\WINDOWS\SysWOW64\cmd.exe  /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login i:\gitpush" >>log1 2>>error    
echo 'done pushing' >>log1
del i:\gitpush

Here is the log output:

'pushing'
Welcome to Git (version 1.7.4-preview20110204)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

Then I did an experiment to rename gitpush script to a wrong file name. And it exited immediately with the error "No such file or directory", which is expected. It shows the gitpush script is passing in correctly to the bash but for some reason it's stuck.

The reason I have to go through git bash shell i开发者_JAVA技巧s because I don't know how to setup public key in windows command line shell without using git bash shell.

Thanks!


I don't know how to setup public key in windows command line shell

Public/private keys work also in a DOS shell, provided you define the %HOME% environment variable (referencing the parent directory of the .ssh)

The trick with Windows Scheduled Task is to make sure:

  • who is actually running the task (the "system account"? or the actual user?)
    Displaying "env" can help debugging the issue.
  • where it is run: if git push depends on the current path to properly push the current repo, you need to be certain that your task runs where it is supposed to.
0

精彩评论

暂无评论...
验证码 换一张
取 消