How to clone other private repos?

One of my android app requires pulling stuff from 2 other private github repos

I setup the main repo so that bitrise can clone from it.

But how do I setup the credentials so that bitrise can pull the other 2 private repo?

Any tutorials for doing that? Currently i am getting

ERROR: checkout (master): Fetch failed, error: exit status 128

For pulling the private repos

1 Like

Hi @liuzhen2008,

To access multiple private repos during the build you have to configure a single SSH key which can access all of those. For more information please see: http://devcenter.bitrise.io/faq/adding-projects-with-submodules/

If you’d have any questions just let us know! :slight_smile:

P.S.: please don’t use multiple Git Clone steps to clone multiple repos, use Git Clone only for the primary repository, and either add the other repos as git submodules to the primary, or use a Script step to git clone the other repos. This is because Git Clone is configured to checkout the branch, commit etc. the build is started with, and e.g. the commit will only exist in the primary repo!

I don’t think github has the ability to have single SSH key to work across repos?

Now, i did generate an SSH key for a particular private repo that needs to be used to build.

What should I do next? Previously I was using a deprecated step github-clone-extended to specify a repo and ssh key. But it seems that it is no longer usable… Now my builds aren’t working anymore =/

@liuzhen2008 Correct. You have to register the SSH key to a user account, as a personal SSH key on GitHub. More info: https://devcenter.bitrise.io/faq/adding-projects-with-submodules/

In this case (e.g. GitHub), there is an easy workaround for the issue. Simply by adding a “bot” / “machine” user with the SSH key to the repositories you can solve the problem. Add the SSH key you would like to use to the user and add the user to the projects. You don’t have to add the “bot” user with read and write permission, it is enough to assign read permissions. After that you can use the SSH key to clone to the repository or any submodule. It’s that simple.

Of course it’s not required to use a special “bot” / “machine” user, you can add the SSH key to your own account on the git hosting service, but the best practice is to use a machine user for this use case, and grant read only access for this machine user, for those repositories you want to access during the build.

If you’d have any questions just let us know! :wink:

Hey. Yeah. I did generate a ssh key pair specifically for bitrise.

My question is, what do I run next? I added the private key to “secrets” and I am able to access it $SECRET_KEY

When I add a script step and run echo $SECRET_KEY i can see it being printed in the lgos.

But what do i do next? How do I use that key to clone my repo?

@liuzhen2008 please don’t add it as Secrets. Follow the guide I linked: https://devcenter.bitrise.io/faq/adding-projects-with-submodules/#when-you-already-registered-your-app-on-bitriseio

Hey @viktorbenei

I am sorry, the guide is really confusing to me. I am new to this thing, so thanks for bearing with me.

Is there a 1,2,3,4 step i could follow somewhere?

  1. How do I register a machine user on github?
  2. Once registered, how do i get an SSH keypair for that machine user for my 2 different repos. Main and an extra private repo.
  3. Once I get the SSH keypair, where do I configure bitrise so that bitrise is able to access the private repo?
  4. Once bitrise has access, what workflow step do I use so that i could clone the second private repo?

I suppose I could just use my personal github account. So that takes care of 1.

How do I do 2, 3 and 4?

Hi @liuzhen2008,

How do I register a machine user on github?

A machine user is just a new account there. Register it the same way you registered your own github account. It’s linked at https://devcenter.bitrise.io/faq/adding-projects-with-submodules/ -> https://developer.github.com/v3/guides/managing-deploy-keys/#machine-users

Once registered, how do i get an SSH keypair for that machine user for my 2 different repos. Main and an extra private repo.

You register a single SSH key, the one you can find on the Settings tab of the app. You can generate a new one there too, as described at https://devcenter.bitrise.io/faq/adding-projects-with-submodules/#when-you-already-registered-your-app-on-bitriseio

Once I get the SSH keypair, where do I configure bitrise so that bitrise is able to access the private repo?

On the Settings tab: https://devcenter.bitrise.io/faq/adding-projects-with-submodules/#when-you-already-registered-your-app-on-bitriseio

Once bitrise has access, what workflow step do I use so that i could clone the second private repo?

The Activate SSH key (RSA private key) step. This should be in the workflow by default, but it might be that you removed it. If it’s not in the workfow, please add it right before the Git Clone step. This step (the Activate SSH key (RSA private key) one) activates the SSH key you have on the Settings tab of the app on bitrise.io on the virtual machine / build machine the build is running on.

1 Like

If you want to we can also look at your project config, just enable Support Access on the Settings tab of the app and copy paste the app’s bitrise.io URL, then we can check the config & advise what’s missing :wink:

This topic was automatically closed after 14 days. New replies are no longer allowed.