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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,240
Community Members
 
Community Events
176
Community Groups

Can I use Bitbucket REST API to clone a repository?

I am trying to find a way to clone all my repositories automatically. However I am not able to find an acceptable way to do the clone. I am writing a C# Console application and the only thing I have managed to get working is using git clone through Powershell using an app-password. However I do not like the idea of exposing my username and password in the url, https://<username>:<app password>@bitbucket.org.... 

I would rather use a rest api where I can add the credentials in a authentication header. However I am not able to find anything on clone in the REST API documentation. What I have tried so far beside this:

  • git commands using ssh but the request of a passphrase every time is stopping me from doing it automatically.
  • Using the lib LibGit2Sharp but I cannot get it to handle long paths over 260 characters
  • Access token and refresh token is a way I cannot see how I could automate from a console app since the tokens will expire in between backup runs.

The solution needs to be fully self sufficient. Is there a way to do that?

1 answer

0 votes

Hi Patrik,

It is not possible to clone a repo via API, this can only be done with Git commands.

You mentioned

git commands using ssh but the request of a passphrase every time is stopping me from doing it automatically.

It is not required to use an SSH key pair with a passphrase. You can generate a new SSH key pair without a passphrase and use that instead.


If you prefer to use OAuth, the access token will expire after 2 hours, but the refresh token does not expire. You can therefore generate a new access token + refresh token using the refresh token from the previous run right before you start cloning the repos, and use the new access token for cloning.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events