This tutorial provides documentation and resources on how to configure Gitlab CI to compile and build your Unreal Engine 4 project. The tutorial is also available on Github.
For our university project we needed a solution for Unreal Engine 4 build automation. After trying Jenkins CI but running into network limitations due to the university network we started using Gitlab CI to automate our builds.
This tutorial and files are based on the great Jenkins tutorial by Zack Devine, check it out if you want to use Jenkins instead!
Before you begin: Set up your Gitlab repository as normal and clone it to your desktop. You can go ahead and add your Unreal Engine 4 project to the repository.
This documentation is solely meant to configure a Gitlab runner on Windows servers and desktops. This may work on GNU/Linux build servers but the included scripts have only been tested for Windows desktops.
We will configure our pipeline so that it will only archive our builds during scheduled builds and manual builds started through the Gitlab interface. This way you prevent flooding your disk space with archived builds.
Gitlab uses runners to run the jobs defined in the .gitlab-ci.yml file (which we will create in the last step of this tutorial). We will set up a Windows desktop as our runner.
Setting up the Runner
Download the runner executable from https://docs.gitlab.com/runner/install/windows.html and follow the installation process described in the documentation.
Register the RunnerNow we need to register our runner. Inside your Gitlab project go to Settings -> CI/CD -> General pipelines settings and obtain the runner token.
Follow the registration progress described in https://docs.gitlab.com/runner/register/#windows but do not enter any tags when prompted. Finaly pick Shell as your executor after which we should have our runner set up.
Download the build scripts and move them to another folder. For example: C:/BuildScripts/.
Configure the Build Scripts
Make sure you replace PROJECT_NAME inside the scripts with the name of your project.
Once we have our runner set up we can configure our pipeline. Start by creating a .gitlab-ci.yml file inside your repository. This file tells the Gitlab runner what to do when a pipeline is triggered.
Creating a Gitlab Pipeline
Add the following to the .gitlab-ci.yml file.
variables: GIT_STRATEGY: none # we disable fetch, clone or checkout for every job GIT_CHECKOUT: "false" # as we only want to checkout and fetch in the preperation stage stages: - preperations - compile - build - cook - package preperations: stage: preperations variables: GIT_STRATEGY: fetch GIT_CHECKOUT: "true" script: - call "C:\PATH_TO_FILES\StartBuild.bat" compile: stage: compile script: - call "C:\PATH_TO_FILES\CompileScripts.bat" build: stage: build script: - call "C:\PATH_TO_FILES\BuildFiles.bat" cook: stage: cook script: - call "C:\PATH_TO_FILES\CookProject.bat" package: stage: package only: - web # only archive when started through the web interface - schedules # only archive when started at a specific schedule script: - echo "Adding build to the artifacts" - call C:\PATH_TO_FILES\Archive.bat artifacts: paths: - PROJECT_NAME.zip expire_in: 5 days
Commit the file and your pipeline should be triggered! Gitlab will now build and compile your project everytime files are pushed to your repository. It will archive the build only when triggered through the web interface or on a scheduled time.
Finaly you might want to add Slack Notifications.
If you have any questions, suggestions or feedback feel free to contact me.