Forum Discussion

TrapMusicJunkie's avatar
TrapMusicJunkie
Copper Contributor
Nov 15, 2023

How to push git repo to Azure Repos with Windows scheduled task?

Hi,

I have created a git repo on my on-prem server where I keep all my scripts. I would like to push this repo to Azure Repos via Scheduled Task in Windows and I can't figure out what am I doing wrong here.

My bash script looks as follows:

 

#!/bin/sh
(
cd E:\Git\Scripts
git add :/*.ps1
git commit -m "Commit message"
git push origin main
) 2>&1 | tee -a log.log

 

It works when executed manually but it does not work when executed via Windows Scheduled Task. Task was configured according to the article below with the difference that I use service account and run the task whether user is logged on or not:

How to automate your git workflow on windows | by Ilesanmi Temitope | Medium

 

I assume that it has to be something with passing through the credentials? Log is not being created  due to fact that script is stuck on "git push origin main" so I need to end it manually.

 

What is the best practice here?

Any advise would be much appreciated.

Regards,

Marcin

Resources