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

How can i upload one file to repo by API?

Paweł Grzyb June 28, 2022

I have set up automatic deployment in my repositories to deploy my PHP / Laravel applications.

Now I need to know how I can upload one * .yml file to my BitBucket repository and to a specific branch.

How can I do this? I am looking for an API that I can send via curl but cannot find a working solution.

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2022

Hello @Paweł Grzyb ,

Welcome to Atlassian Community!

My understanding is that you would like to commit a file to your repository for a given branch by using the Bitbucket API. If that is the case, you can use the Create a commit by uploading a file endpoint , as per the example below : 

curl  --user USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/src \
  -F /path/within_repo/my_test_file.txt=@local_file_to_be_commited.txt \
  -F "message=This is the commit message" \
  -F "author=Name <e-mail address>" \
  -F "branch=my_branch" 

For the authentication, you will need to provide your bitbucket username (not e-mail address) which you can find under your account's personal settings, along with an App Password (not the account password).

Also, the command above considers the file you are trying to upload (local_file_to_be_commited.txt) is in the same directory where you are executing the curl command.

You can try the above suggestion and let us know how it goes.

Thank you, @Paweł Grzyb .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events