Missed Team ’24? Catch up on announcements here.

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

How to clone the contents of one bitbucket project to another project ?

Carthik Annayan July 7, 2019

Hi There, 

 

I'd like to clone the contents of one bitbucket project to another project. Is this feature available at this stage? Please let me know.


Regards, 

Carthik

1 answer

0 votes
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 8, 2019

Hello @Carthik Annayan,

Before I answer your question I'd want to confirm I understood it correctly.

Do you mean cloning contents of a single repository or a project, which is essentially a group of repositories? Just wondering whether you referenced a repository as a "project".

Cheers,
Daniil

Carthik Annayan July 8, 2019

Hi Daniil, 

 

I have many repositories in a single project. Precisely, I'd like to clone the contents of one project to another. Your understanding of my question seems to be partially correct. I wanted to clone the Contents of a "PROJECT" to a "NEW PROJECT" this should include all the repositories within the project. 

You help and any quick response is much appreciated. Also, the bitbucket documentation is not very helpful to identify the API's to be used.

Regards, 

Carthik

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 8, 2019

Hi @Carthik Annayan

Thanks for the clarification.

Unfortunately, there's no option of batch copying of all repositories within a project into another project as this use case doesn't look common. You can only copy repositories one by one. I can think of two options:

  • fork each repository into another project. In this case the repos will be "linked", giving you ability to create a cross-repository pull requests (from fork to the upstream) and to sync the state of the fork with the upstream, if needed.
  • import each repository into another project. In this case the imported copy will be completely unrelated to the origin.

Hope this helps.

Cheers,
Daniil

Carthik Annayan
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 8, 2019

Hi Daniil, 

 

Thanks for your quick turn around. We have a list of projects and the structure is messed up. We like to use your API's/bash script to achieve the following 

 

1. Create a Project using API

2. List the contents of an existing project using API/git command

3. Clone the repos one by one from the existing project using API/git command

4. Change the remotes for all the repos using API/git command

5. Push all the repo's to the new project using API/git command

 

Your help in this regard is much appreciated. 

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 9, 2019

Hi @Carthik Annayan,

Unfortunately, step 4 (change remotes) won't work as the repository clone URL doesn't have project in it, only workspace and repository slug.

Is your final goal to copy or actually move repositories from one project to another?

Cheers,
Daniil

Carthik Annayan
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 9, 2019

Hi Daniil, 

Yes, that's correct. But we have 24-28 such Projects which I'd like to move an organized in a structured manner. May be steps 5 and 4 should be interchanged? your thoughts and ideas are most welcome.

I look forward to hearing from you.

Cheers, 
Carthik 

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 9, 2019

Hi @Carthik Annayan,

I understand what you're trying to achieve, however I'm afraid there's no good way of automating this process.

As I said, you can't copy or move a repo from one project to another by cloning and then pushing it up again – because the clone URL does not include project, projects are server-side entities used for grouping repositories. That said, clone URL does not change if you move a repo from one project to another. So step 4 won't work because the clone URL remains unchanged, hence step 5 is a no-op.

What you can do is go to the repository settings UI and change the project that repository belongs to, but this is manual per-repository process, the only thing that you can automate is prepare go-to links for every repository.

 Repository details — Bitbucket 2019-07-10 02-09-14.png

Unfortunately I'm not aware of any API that could help with moving repositories around, sorry.

Cheers,
Daniil

Carthik Annayan July 9, 2019

Hi Daniil, 

Thanks for your response. I'm surprised and disappointed that we can't automate this. Having said that, can you point us to the actual payload, API to create a Project for bitbucket API Version 1

 

Regards, 

Carthik

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2019

Hi @Carthik Annayan,

Here's the document describing the endpoint to create a project. Note that it is a v2 endpoint, because v1 API has been deprecated about a year ago and removed recently, check out details on this.

Hope this helps.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events