Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to push code into bitbucket using azure powershell in Azure devops pipeline

ssreshta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 20, 2020

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 executed/to be executed) and execute all the sequence of scripts. upon execution, the flag in JSON file 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: myusername 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://myusername:$MyPat@bitbucket.org/xyz/abcd.git

getting the error,"##[error]fatal: Not a git repository (or any of the parent directories): .git" while issuing push as above but when issuing
git clone https://myusername:$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://myusername@bitbucket.org/xyz/abcd.git

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events