Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows scheduled task to git push to github

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 is because I don't know how to setup public key in windows command line shell without using git bash shell.

Thanks!

like image 669
PokerIncome.com Avatar asked Jul 21 '11 00:07

PokerIncome.com


People also ask

Can we automate git push?

Buddy CI/CD allows you to instantly implement Git Push with 100+ ready to use actions to automate your development and build better apps faster.


1 Answers

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.
like image 79
VonC Avatar answered Sep 28 '22 01:09

VonC