Skip to main content
Version: v4 (current)

Getting started

This guide will demonstrate how to setup build and test automation for your Unity project hosted on gitlab using gitlab-ci.

Overall steps

  1. Understand how gitlab-ci works.
  2. Configure a license for Unity.
  3. Add build scripts and integrations in your Unity project
  4. Set up a gitlab-ci pipeline for your project.
  5. Result: Accept merge requests with more confidence.

First time using Gitlab CI?

Read the official documentation about Getting started with GitLab CI/CD.

Any subsequent steps assume you have read the above.

Supported versions

The unity3d-gitlab-ci-example project is based on unity3d docker images from game-ci. Any version in the docker hub unityci/editor tags list can be used to test and build projects.

It's generally considered good practice to use the same Unity version for your CI/CD setup as you do to develop your project.

Video tutorial

Setting up gitlab-ci for your Unity project

I don't have a Unity project yet

  1. Fork the unity3d-gitlab-ci-example project
  2. Clone the fork you just created locally
  3. Continue to activation instructions

I already have my own Unity project

  1. Clone the unity3d-gitlab-ci-example project
  2. Copy .gitlab-ci.yml to the root of your repository, Assets/Scripts/Editor/BuildCommand.cs and ci folder to your project:

Assuming you've cloned the example project in the parent folder of your project, and your Unity project is at the root of your repository, execute these commands from the root folder of your project:

mkdir -p Assets/Scripts/Editor/
cp ../unity3d-gitlab-ci-example/.gitlab-ci.yml ./
cp -r ../unity3d-gitlab-ci-example/ci ./
cp ../unity3d-gitlab-ci-example/Assets/Scripts/Editor/BuildCommand.cs ./Assets/Scripts/Editor/
  1. Open and edit the .gitlab-ci.yml you copied to your project and update the variables with the versions you need. Your Unity project version can be found in ProjectSettings/ProjectVersion.txt.
  2. If your Unity project is not at the root of your repository, also update UNITY_DIR variable.
  3. Continue to activation instructions