Unreal Engine TeamCity build configuration

Test, build and deploy your unreal engine project with TeamCity

Thu, 08 Jun 2023

My current TeamCity build configuration is a bit dated since I’ve paused on game development to work on my Housemates App. This was the first TeamCity config that I made, it does work but I think I can set it up smoother. Once I continue working on my game later this summer/early fall I will create a new post with the updated config

Structure

So the original structure of my config was set to have 3 build configs, one for deployments, one for builds and one for testing. For this guide I’m just going to post the individual steps. Like I said, its outdated, but each step should be valid if you do want to use it

Engine

You can use the same engine you develop on, I personally advise against it because I have ran into issues where my builds failed or my personal work had to be paused for a build since the engine can only build one process at a time. Instead I opt for docker containers. This is a whole post on its own, but I do utilize the ue4-docker and ue4-cli tools made by Adam Rehn. These make the build process so much smoother and keeps the engine contained. The biggest caveat is that you will need about 600GB to build the images and 150GB to store the final image

Parameters

Because I like templates, this is how I made this reusable for any unreal engine project

GameName - name of your game/project UE4 - Path to the unreal_editor.exe file

Build Features

XML Report Processing - This is how team city picks up our Junit report thats created in step 3 of the tests section Perforce Administrator Access - This is a project level feature that you can access in the Connections section. While its not a build feature its worth mentioning because TeamCity will clean up inactive workspaces which is huge for me. I build a lot of streams and I’m still using the free 20 workspace license. Without this on I do hit my limit often which then requires me to go and manually delete what isn’t active

Tests

  1. The first step is to build the editor. I do this with the ue4-cli tool mentioned earlier. You want that tool inside your path and once it is your script will look like this
ue4-cli build Development Editor
  1. This next step is optional, I lint my code and parse the results to TeamCity’s code inspection tool

I created my own cli to help out with the parsing and I use the linterv2 plugin. If this tool doesn’t get an overhaul this summer I will be building a proper engine plugin that will be able to do all of this in one so you don’t need multiple tools. This build step looks like this. The first step runs the linter and prints out a JSON report, the second step then reads that JSON report and reports the results to TeamCity

%env.UE4% run -run=Linter -RuleSet=ue4.style -TreatWarningsAsErrors /Game/%env.GAME_NAME% -json=Lintreport.json -nullrhi
%teamcity.build.workingDir%\\bin\\ue4-ci.exe teamcity parseLintReport --json %teamcity.build.workingDir%\Saved\LintReports\Lintreport.json

The goal of this is to create a tab like this in your project config. This will list all inspection issues and you can define parameters for which allowances you will tolerate. For example, you may allow 5 warning level issues and 0 error related

team city inspection

  1. Finally we have unit tests. I utilize the same two tools for step 2 to create these. I will write out a post when I start working on my game again to how I make my functional tests to test my game
%env.UE4% test Project -- ReportOutputPath=%system.teamcity.build.workingDir%\\Saved\\Reports
%teamcity.build.workingDir%\\bin\\ue4-ci.exe jsonToXml -j %system.teamcity.build.workingDir%\\Saved\Reports\\index.json -o %system.teamcity.build.workingDir%\\Saved\\Reports\\.xml -t '%Game_Name% Test Suite'

The first step runs all tests listed under the Project category. This will automatically pick up any tests you make in the editor. I think save the report and parse it in the second step. The -t option lets me specify the name of the test suite

Build

  1. I use my cli tool I created before to update the project version of the game before I build it. This is to ensure I know which build is being tested
attrib -r %system.teamcity.build.workingDir%\\Config\\DefaultGame.ini
%teamcity.build.workingDir%\\bin\\ue4-ci.exe projectVersion set -i %teamcity.build.workingDir%\\Config\\DefaultGame.ini -s %build.number%

The project version is found in DefaultGame.ini, the first step is to make this file writable. The second step is to run the cli command, it basically just searches for the projectVersion key in the ini and then replaces its value with the current build number from TeamCity

  1. Build the game. I don’t know if this is fixed yet but the engine was adding a Hololens platform to my game even though I disabled Hololens. Since I run a barebones engine for what I need the platform isn’t installed so it created build issues for me. I delete the config in the engine that makes it look for Hololens before I start my build process and then I build the game
del C:\UnrealEngine\Engine\Intermediate\ScriptModules\HoloLens.Automation.json 2>nul
%teamcity.build.workingDir%\\bin\\ue4-ci.exe clean dist --directory %system.teamcity.build.workingDir%\dist
%env.UE4% package Shipping

Steam Deploy

The final step is the steam deployment. I use the windows version of steam, I might mess around with Linux again to see if I can get the deployments working in linux. If I can, I just might make my own private image with the SDK and be able to deploy it from any platform. At the time of writing this, this config only works on windows

xcopy %system.teamcity.build.tempDir%\Windows %system.teamcity.build.tempDir%\steamsdk\tools\ContentBuilder\content\ /E /H

This command will copy my final build and put it in the ContentBuilders directory to prep the deployment.

%system.teamcity.build.tempDir%\steamsdk\tools\ContentBuilder\builder\steamcmd.exe +login %env.STEAM_USER% %env.STEAM_PASSWORD% +run_app_build_http %system.teamcity.build.tempDir%\steamsdk\tools\ContentBuilder\scripts\%VDF_FILE% +quit

Rather than same the username and pw in TeamCity I saved them on my local machine. This will deploy my game to steam

Buy Me A CoffeeDigitalOcean Referral Badge
Loading...
Edward Beazer

Edward Beazer - I just like to build shit. Sometimes I get stuck for hours, even days while trying to figure out how to solve an issue or implement a new feature. Hope my tips and tutorials can save you some time.

DigitalOcean Referral Badge