2026-10-25
Building Unity for Four Platforms in One GitLab Pipeline
Agate's projects share one GitLab CI/CD template. When I started, it could build Unity projects for WebGL and Windows. Game teams also needed Android and iOS, ideally from the same config and without one platform's build getting in the way of another. These are my notes from that work, including the parts that are not finished yet.
Picking the right Unity
The new Android and iOS jobs run inside Docker on a shell runner. Each job reads the Unity version from the project's ProjectVersion.txt instead of trusting a variable someone has to keep in sync, then pulls the matching Unity Editor image from the internal registry. If that image is not there, the job falls back to a public GameCI image so the build can still run.
Android builds produce an APK plus OBB. iOS builds produce an Xcode project, because turning that into an IPA needs macOS, which the runner does not have.
One list, one job per target
Projects choose their platforms with a single variable, VAR_BUILD_TARGET, which can hold a comma-separated list such as webgl,windows,android,ios. A generate stage validates that list before anything expensive happens: it cannot be empty, cannot contain duplicates, and every target must be one the rules know about. Then the stage creates one build job per target.
Each target gets its own Library cache and its own log. Unity's Library folder is large and platform-specific, and keeping it separate per target stops one platform's build from interfering with another. That made parallel builds predictable.
Failures you can read
A Unity build that fails in CI usually leaves a long log and a vague exit code. The after_script now always keeps build.log as an artifact, even on failure, and prints the lines that matter in the job output: the error lines, Debug.LogError messages, and exception stack traces. Most of the time the cause is visible without downloading anything.
The pipeline was tested on a QA sandbox project with all four targets in one run, so the generate stage, the parallel jobs, and the error summary were exercised together rather than one platform at a time.
What is still rough
In October I added Android keystore support, mounted read-only into the container, and detection of AAB output for Google Play. An AAB build of about 1.31 GB succeeded on one of the studio's projects. When I wrote my internship report, that AAB support was still on its own branch and not yet merged into the main template.
Two other limits are worth knowing. iOS stops at the Xcode project, so shipping to the App Store still needs a Mac step outside this pipeline. And the job finds the project's build method by searching the code as text, which works for the projects I tested but is fragile. Writing these limits down was part of the work, so the next person knows where to start.
More articles
How I Build Internal Tools AI-First
How I built four internal tools during my DevOps internship: writing the specs, letting AI coding agents write the code, and trusting tests.
Giving Access Without Sharing Credentials
Lessons from two internal tools that let people use SVN and SSH without holding the credentials: scoped grants, one access check, and lasting logs.
Smoke-Testing Docker Images Before They Deploy
Why a green Docker build is not proof that an app starts, and how a smoke-test stage in GitLab CI checks the exact image before it deploys.
LET'S WORK TOGETHER
akmalzaidan960@gmail.com


