I have written a PowerShell script to force push just a text file with version number(nuget package version to link with commit number) into server git-tfs repo and this script works perfectly fine when run manually(powershell ISE) on build server/machine (have rights to force push). But when I try to run this on same machine through a VSTS agent(CI build), the build gets hung exactly when trying to push to the server and also when I log into that build machine I don't see any prompts for credentials. Please let me know if I am missing any thing here, because the same process works successfully with TFVC repository.
The script is as follows:
$BuildVersion = "0.1.0"
$source_dir = "$env:SYSTEM_DEFAULTWORKINGDIRECTORY\***\**.txt"
git checkout develop
New-Item $source_dir -type file -Force -value $BuildVersion
git add $source_dir
git commit --amend --author="buildservice@***.com>" -m "NuGet package version check-in as part of build: $BuildVersion ***NO_CI***"
git push origin HEAD:develop -f