Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Download a single file from bit bucket repository using Powershell

Chandramouli Puvvadi
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!
October 5, 2018

I want to download a specific file ("Web/Externals/Settings.txt") in a folder(which is not having git) from my bit bucket repository "TestRepository" with branch name "TestBranch".

Please suggest

 

Note: I need the file as it is.

1 answer

0 votes
Chandramouli Puvvadi
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!
October 9, 2018
function CheckOutDevFile($userName, $password, $CheckOutFilePath, $RepoUrl){
$userNamePaswords = "$($userName):$($password)"
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($userNamePaswords))
$authorization = "Basic $encodedCredentials"
$Headers = @{ Authorization = $authorization }

Invoke-RestMethod -Headers $Headers $RepoUrl -OutFile $CheckOutFilePath
}


$userName = 'Your User name'
$password = 'Your password'
$CheckOutFilePath = 'Your out put location with file name'
$RepoUrl = 'https://{CompanyRepoUrl}/projects/{PojectName}/repos/{RepoName}/raw/{SpecificFilePath}?at=refs/heads/{BranchName}'

CheckOutDevFile $userName $password $CheckOutFilePath $RepoUrl
Stamatis Tiniakos
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!
September 10, 2020

I have tried that and I get the following error: 

Invoke-RestMethod : Unable to connect to the remote server

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events