I am writing an Azure PowerShell script that will consume the JSON file which has the location of all my SQL scripts and Migrationflag column (which holds to execute/to be executed) and execute all the sequence of scripts. upon execution, the flag will change to 'N' and the updated JSON file should be uploaded to bitbucket. Now, I am stuck with "fatal: not a git repository (or any of the parent directories): .git" error while trying to push.
I've created a pat token and service connection with username: santhoshsreshta and below is the code to push.
$v_JSON = Get-Content '$(system.defaultworkingdirectory)\locationToBuild\BuildOrder.json' -Raw | ConvertFrom-Json
$v_JSON | Sort-Object -Property OrderNo | Where-Object {$_.MigratedFlag -like 'Y'} | ForEach {
$Script = $_.Location
Write-Host "Executing Script: $Script"
Invoke-Sqlcmd -ServerInstance "myservername" -Database $(database) -Username $(testauto_username) -Password $(testauto_password) -InputFile $(system.defaultworkingdirectory)\$Script
$_.MigratedFlag = 'N'
}
$v_JSON | ConvertTo-Json -depth 32| set-content '$(system.defaultworkingdirectory)\locationToBuild\BuildOrder.json'
$MyPat = 'mypatcode'
git push https://mygitusername:$MyPat@bitbucket.org/xyz/abcd.git
getting the error,"##[error]fatal: Not a git repository (or any of the parent directories): .git" but when issuing git clone https://mygitusername:$MyPat@bitbucket.org/xyz/abcd.git -- getting invalid username/password error. I believe we should not clone again as my pipelines get sources task will clone it and puts in a self-hosted agent.
this is my git url: https://mygitusername@bitbucket.org/xyz/abcd.git
Thanks a ton, A DevOps, PowerShell newbie here.