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. Add build scripts and gitlab-ci integration in your Unity project
  3. Configure a license for Unity.
  4. Successfully build and test your Unity project ๐ŸŽ‰

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 uses unity3d docker images published by game-ci.

tip

Before proceeding, verify that your Unity version is supported by checking the Docker > Versions page.

It is generally considered good practice to use the same Unity version for your CI/CD setup as you do to develop your project. Our Gitlab CI configuration will automatically detect and use the correct Unity version for your project.

Video tutorialโ€‹

caution

The video (recorded with Unity 2020.x) is slightly outdated, but the general concepts are still the same. ๐Ÿ‘

  • The activation process has changed a bit since then.
  • Docker images have been updated
  • The .gitlab-ci.yml file uses different variables now.

Steps to Set Up Unity CI/CD with GitLabโ€‹

1. Clone the Example Repositoryโ€‹

Start by cloning the GameCI example project provided by GameCI to use its configuration files.

git clone https://gitlab.com/game-ci/unity3d-gitlab-ci-example.git

2. (Optional) Checkout a Specific Versionโ€‹

If you want to use a specific version of the example project, checkout the desired tag.

cd unity3d-gitlab-ci-example
git checkout v4.0.0
cd ..
info

See example project's release for stable versions.

3. Navigate to Your Unity Projectโ€‹

Replace your-unity-project with the actual name of your Unity project folder.

cd your-unity-project

4. Create Necessary Directoriesโ€‹

Create the required directories in your Unity project to hold CI-related files.

mkdir -p Assets/Scripts/Editor/

5. Copy Required Filesโ€‹

Copy the necessary CI configuration and scripts from the example project to your Unity project.

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/

Final Note:โ€‹

If your Unity project is not at the root of your repository, update the paths accordingly in the commands above and in the .gitlab-ci.yml file. Adjust the UNITY_DIR variable in .gitlab-ci.yml to point to your project directory.

Proceed to activationโ€‹

Thatโ€™s It! You're one step away from having automated builds and tests for your Unity project. Proceed to the Activation guide.