Search Unity

Using Cloud Build with Gitlab

Discussion in 'Unity Build Automation' started by Afropenguinn, May 17, 2016.

  1. Afropenguinn

    Afropenguinn

    Joined:
    May 15, 2013
    Posts:
    305
    I am having some trouble getting Unity Cloud Build access to my project on Gitlab. I added the SSH key that Unity Cloud Build generated for me to the deployment keys on my project, but it still won't go past that step where it gives me the key.
     
  2. crag

    crag

    Joined:
    Dec 13, 2013
    Posts:
    145
    @Kristian221 did you figure this out? if so, would you mind sharing your solution?
     
  3. Afropenguinn

    Afropenguinn

    Joined:
    May 15, 2013
    Posts:
    305
    Yeah, I was using http when I needed to be using SSH. It still doesn't work though, due to Gitlab not supporting Git LFS through SSH and Unity Cloud Build not supporting Git LFS through HTTP.
     
  4. ForestGamesCorp

    ForestGamesCorp

    Joined:
    Nov 11, 2014
    Posts:
    1
    Solved, here are the steps.

    Let's assume that:
    • you already have a gitlab account
    • you have a gitlab project
    • you have your gitlab project checked out
    • you've added/committed/pushed your Unity project into your gitlab project.
    • you can view your project and its contents on the gitlab project page.
    I'll note that Chrome is not well-supported in Unity's admin webpages; prefer Firefox.
    Also all of this will almost certainly change in time.

    Steps to make Unity Build create builds of your project in GitLab:
    1. Start Unity
    2. Open your project
    3. Click in main menu: "Window/Services" or press ctrl-0
    4. Set up the Unity Project ID. Create a new one in the chosen (Unity account) organization, or choose an existing Unity Project ID. A list of services are shown.
    5. Click Cloud Build or its button which should be in the OFF state
    6. Click "Start using Cloud Build". A "Source Control" config page is shown.
    7. Set "Select source control host type" to "GIT"
    8. Go back to your GitLab project page in a browser. In the center of the page there's a text field with the project's git url. Select "SSH" then click the copy-to-clipboard button. The project's git url using ssh protocol is now in your clipboard.
    9. Back to Unity, paste the clipboard in "Source control hosting url". Click next.
    10. If you have a private project:
      1. A page called "Grant Access" may be shown if you have a private project. Unity will generate a unique ssh key. Copy it to your clipboard.
      2. Go back to your GitLab project page in a browser.
      3. Click "Settings", then "Repository." So top menu is "Settings", sub menu is "Repository".
      4. A page "Deploy Keys" is shown. paste that key into the field "Key".
      5. Enter a meaningful Title, say the name of your project + " Unity SSH key"
      6. Click Add Key. If you refresh the page, you'll see your new key there somewhere after some Ajax-loading-goodness.
      7. Back to Unity. Click next.
    11. Platform config page is shown.
    12. Pick your platform you'd like to build to. Click next.
    13. Target setup config page is shown.
    14. Credentials page may be shown for some platforms, Android, iOS etc. You might have to enter the same bundle ID as in your build settings.
    15. You can set up additional stuff here:
      1. If your branch is empty, your gitlab project's default branch is used. That default is master, but you can override that in gitlab, and/or specify the branch here.
      2. "Project Subfolder:" in some projects you may have an extra directory, say C:\Work\AftropenguinnProject\AfropenguinnProjectUnity. In that case if git's root is C:\Work\AftropenguinnProject then enter "AfropenguinnProjectUnity"
      3. "Auto-build:" this will watch your repo for changes and build automatically when new changes are committed. Very useful.
    16. Click Build. The "regular" Cloud Build settings are shown. Here you can see the status of builds, kick off new ones, etc.
    Hope that helps!
     
    MansyrevAY, WhiteGfx, Novack and 3 others like this.
  5. Afropenguinn

    Afropenguinn

    Joined:
    May 15, 2013
    Posts:
    305
    Actually, this issue should be resolved now, as GitLab currently supports git-lfs through SSH.
     
  6. Naphier

    Naphier

    Joined:
    Aug 4, 2014
    Posts:
    114
    I'm stuck at the SSH key. GitLab says the fingerprint is already taken... I tried putting it in the deploy keys for the project and no-go. So I tried putting it in my profile/account's keys and still "fingerprint is already taken". Any help is appreciated.
     
  7. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    This can happen if you have two accounts with the same fingerprint. It's using a rather short hash, I guess, so it could collide. Generate a new key pair and try again.
     
  8. Naphier

    Naphier

    Joined:
    Aug 4, 2014
    Posts:
    114
    Any idea how to generate a new key? Unity's only displaying the one key (in the editor and the cloud build website).
     
  9. Naphier

    Naphier

    Joined:
    Aug 4, 2014
    Posts:
    114
    Nevermind! I only needed to scroll down to see that there was an OLD project where I tried to set up Unity Cloud Build. So it seems that I can only have ONE repo on GitLab with this SSH key and unity cloud build? Or can I add the SSH to my account and then that will filter through to all projects? Not sure that's ideal though...
     
  10. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    You should ideally have one key-pair for each connecting system/account. So all the ones on UCB should be fine sharing a key, added only once on GitLab. A pair per project would get unwieldy :)
     
  11. Naphier

    Naphier

    Joined:
    Aug 4, 2014
    Posts:
    114
    Then I guess instead of adding it to the Deploy Keys of a project I'd have to add it at a user level? Makes sense, I have my suspicions it won't work. Not really sure that a pair per project would be unwieldy, I mean we maintain a keystore per project and lots of things per project, but per machine makes sense for SSH keys as long as it actually works.,,
     
  12. GaelFG

    GaelFG

    Joined:
    Dec 16, 2016
    Posts:
    5
    A bit late but for the record @Naphier it's the gitlab ui which is a bit tricky.

    You must REGISTER your Deploy Key only once (and REGISTERING the keu automaticaly ADD it to the current project when you fill the form).

    To simply ADD a Deploy Key on an other project on your gitlab instance you have to go a bit down, under the key creation form (red arrow on my screenshot) :

    upload_2020-1-24_17-5-45.png

    Here you will find your previously added unity cloud Key under 'privately accessible deploy keys'

    Then you can enable the key. The key will go into 'Enabled deploy keys'.
     
  13. majaus

    majaus

    Joined:
    Jan 15, 2016
    Posts:
    3
    @Keleben i dont understand why it work, but it work, thanks!!