Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Git error when cloning build with submodules

Discussion in 'Unity Build Automation' started by marioslokas-v, Dec 9, 2020.

  1. marioslokas-v

    marioslokas-v

    Joined:
    Aug 19, 2020
    Posts:
    12
    Hi,
    I have tried cloud build with multiple of my projects so far, and it has been working great. I now want to use it for projects that are using private submodules. All these projects are parts of an organization where I have access. UCB is working fine for projects in the organization as long as they are not using submodules. However, if a project is using one, I get the following error:

    GIT: Error during clone: /usr/local/bin/git clone '--branch' 'master' '--recursive' '--' 'git@github.com:compName/projectName.git' '/BUILD_PATH/compName.projName.default-android/' 2>&1:Cloning into '/BUILD_PATH/compName.projName.default-android'...
    2: Finished: FAILURE


    Reading about it at the forums and the docs, I found out that the submodules need to use the git@github.com syntax for the submodules. Changing my .gitmodules file to the following:


    Code (CSharp):
    1. [submodule "Assets/SubmoduleLocation"]
    2.     path = Assets/SubmoduleLocation
    3.     url = git@github.com/CompanyName/submoduleName.git
    still does not work! The error this time is:
    Code (CSharp):
    1. OAUTH: Error during checkout: bad URI(is not URI?):
    2. Finished: FAILURE
    Some sources suggest that the syntax for the url is actually "git@github.com: ...." (no forward slash). Both result in the same error above.

    I am 80% sure that it's the submodules fault, even though there is no explicit error declaring that. Anyone who has experienced this before?

    EDIT:
    After checking the full log, I get the error
    fatal: repository 'git@github.com/CompName/SubmoduleRepoName.git' does not exist
    So it is the submodule after all.

    EDIT:

    Trying to clone the submodule locally on my computer returns
    Code (CSharp):
    1. git@github.com: Permission denied (publickey).
    2. fatal: Could not read from remote repository.
    So it might be an SSH thing.
     
    Last edited: Dec 9, 2020
  2. victorw

    victorw

    Unity Technologies

    Joined:
    Sep 14, 2016
    Posts:
    459
    Yeah you need to make sure that the Cloud Build SSH key has been granted access to the submodule repo as well as the repo you're cloning, that's a common issue users encounter. Syntax for the submodules shouldn't matter, the syntax restrictions are only required by oauth (caused by limitations of the git client HTTPS auth).
     
    marioslokas-v likes this.
  3. marioslokas-v

    marioslokas-v

    Joined:
    Aug 19, 2020
    Posts:
    12
    Thanks for your answer. Trying to add the SSH key as a deploy key in the repository returns "Key is already in use". Does this mean I have to regenerate the public SSH key for cloud build?

    EDIT:
    I regenerated the key, and added it to the repo I want to use UCB for. The problem persists, as the submodules do not have that key set as deploy key. Trying to add that key to the submodules as well returns the error "Key is already in use", which is expected as one can use an SSH key only once. The github docs suggest to create machine users that use the one SSH key, which I am unsure as to how it would work with UCB.
     
    Last edited: Dec 11, 2020
  4. marioslokas-v

    marioslokas-v

    Joined:
    Aug 19, 2020
    Posts:
    12
    I have researched more and still couldn't find a solution.What I know so far is:
    1. I need to use SSH for my cloud build to work with private submodules.
    2. You only get one SSH key from UCB.
    3. This SSH key can be added to only one repository.
    4. Trying to add the UCB SSH key to the private submodule repo returns "Key is already in use."
    5. Cloud build fails every time with "submodule repository cannot be found"
    I guess I am not the only developer who is trying to use UCB with Github and private submodules. Any one has any idea about this?
     
    thecloudkeeper likes this.
  5. CarlosVazquezG

    CarlosVazquezG

    Joined:
    Apr 2, 2019
    Posts:
    4
    This is not exactly our situation, even when we are using submodules too, but we are getting the same error generating builds since around 20 hours ago.
    Maybe Unity is having any sort of internal problem? Sorry if this is not that case but as far as we can see, everything seems fine from our side :(
     
  6. victorw

    victorw

    Unity Technologies

    Joined:
    Sep 14, 2016
    Posts:
    459
    How are you configuring the SSH key? If you're following the steps listed on the SSH setup page then you should be associating the SSH key with an account. In this case, the SSH key should have access to all the repositories that account is associated with - no need to add the same key multiple times.

    Screen Shot 2020-12-15 at 11.01.30 AM.png
     
    marioslokas-v likes this.
  7. marioslokas-v

    marioslokas-v

    Joined:
    Aug 19, 2020
    Posts:
    12
    I have been a bit confused about this while trying to resolve the whole thing, so I have been moving the SSH key around as deploy key and as a key into my account, same way as it is described in your image. Last thing I tried was adding it as described and that still does not work.
     
  8. marioslokas-v

    marioslokas-v

    Joined:
    Aug 19, 2020
    Posts:
    12
    Alright, I figured it out. Turns out the problem was on my side, the git@github syntax for the submodules was wrong by a "/" instead of a ":". When I actually had the syntax fixed, the SSH key was not added into my account, and so the confusion arose. For anyone having similar problems, check the syntax for the submodules you are using thoroughly.
     
    victorw likes this.