Is there a way i can clone all the existing repositories from a project in stash in a simple way?
Lets say I have project called "A" and there are 5 reporitories say 1,2,3,4,5. I would like to clone all the repositories in project A in a simple way rather than doing
git clone http://mystash.com/A/1.git
git clone http://mystash.com/A/2.git
git clone http://mystash.com/A/3.git
git clone http://mystash.com/A/4.git
git clone http://mystash.com/A/4.git
thanks!!!
Hi Vishal,
I'm afraid Git doesn't allow that, they have to be cloned separately.
Hypothetically you could have another repository that uses Submodules to link to the others, and then use git submodule to clone them down. You would have to keep that other repository up-to-date, which would be a pain. Submodules link by using commits. I personally wouldn't recommend that - it's not really buying you much.
You could also write a script that uses Stash's REST resources to list the repositories in a project and then clone them all in succession.
I'm curious - how often are people clone the repositories? Once you have them locally you dont' really need to clone them again. Is this for a build perhaps?
Cheers,
Charles
Hey charles - Thanks for the prompt response. Yes it is for the build purpose. I will be working all the repositories of all the projects from various teams. I want a simply way to clone all repositories.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishal,
I thought so. :)
So it's gets interesting at this point. What kind of dependencies do you have between each of your repositories then? If you clone them all down, how do you know what version/branch of each repository to build? Is it always master? If that's the case how do you handle old release versions?
Generally I would recommend that you would except one build per repository. So what we do here is use maven as our dependency management, and we use maven versions to tie two separate repositories together. It means we can make changes to one repository without affecting another.
You might find that submodules are an easy(ish) way to get started with this kind of versioning. As mentioned previously, you can have another repository would would then 'link' all of your child repositories together at specific versions. You would then need to modify this parent repository before changes in a child repo was built. This may or may not be what you are looking for. Depending on your language/environment you might be able to use something like Ruby Gems, Python Eggs, etc. I would recommend these over using submodules, but would require a more substantial change to your build process.
The quick answer to your actual question would proably be to just configure your build (Bamboo? Jenkins?) to clone each repository manually. I know in Bamboo you can have multiple repositories per plan. It's not really an automated solution - but it's probably the easiest (assuming you don't have like 100 repositories).
Sorry for the long rant.
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Charles -
There is no dependency between the repositories. I want latest version of code of all the repositories to be available. We will build anything which is latest and yes it is always master. I am handling old releases with TAG's.
I have around 20 repositories. And My build system(Jenkins) is configured to build individual repositories. Its just my individual request that I want to clone each and every repository in stash.
I will try submodules and thanks again!!!
-Vishal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is quick script using stashy - a python rest api client for stash: https://github.com/RisingOak/stashy
# stashget PROJECT_KEY
#!/usr/bin/python import sys import os import stashy stash = stashy.connect("http://localhost/stash", "USERNAME", "PASSWORD") for repo in stash.projects[sys.argv[1]].repos.list(): for url in repo["links"]["clone"]: if (url["name"] == "ssh"): os.system("git clone %s" % url["href"]) break
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Faik, works awesome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need create ssh key!
Steps: Open Terminal
ssh-keygen
pbcopy < ~/.ssh/id_rsa.pub (This command copied clipboard your ssh key)
1)Go to your stash site. Click Manage Account Tab2) Click Add key Button
3)Paste (ctrl + v) Key Area -> Click Add key button
4-> Run your python script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Faik this worked great!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're using git bash or cmd in your local (which I think most of us use)
you can just type the following
for i in reponame1 reponame2 reponame3 ...
do
git clone http://username@bitbucketaccount.com/scm/"projectcode"/$i.git
done
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Divin Honnappa thanks that was simple and effective
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
$ curl -s -k --user YourUserName https://api.bitbucket.org/1.0/user/repositories | python -c 'import sys, json; r = json.loads(sys.stdin.read()); [sys.stdout.write(d["name"]+"\n") for d in r]'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
goood
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using @archenroot answer ,I have created a repo with springBoot Rest api to clone all repos from url.
https://github.com/enesacikoglu/BitbucketRepoCloner
Thanks to archenroot
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys, I found this discussion while looking for similar solution. The python stashy didn't work for me, so I wrote simple Java app which do the same:
https://gist.github.com/archenroot/1d11f58d182163ce55bdafcdfe11d411
It actually access all projects where user has permission to read, iterate trough all repositories of all projects and clone them to directory structure:
project1
|---- repo1
|---- repo2
project2
|---- repo1
|---- repo2
etc..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are facing the same problems with > 50 projects and > 100 repositories. Most of them are built with Jenkins .
There is one project to configure the build jobs of Jenkins and I am working on the small management component (internally called "Metagit"). This is based on the stash-java-client (https://bitbucket.org/atlassianlabs/stash-java-client/) and uses Ant as a frontend.
We automate the following workflows:
1. Pull / Clone a set of repos
2. Create a feature branch
2a. Search and modify (if needed) e.g. Maven versions ...
2b. Commit and Push
3. Create a Pull Request for the new branch
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.