How to set up automated Unreal builds using Jenkins CI

How to set up automated Unreal builds using Jenkins CI

I was having way too many issues with simply setting up Jenkins to automatically build my Unreal Engine projects. For an unexperienced designer like me it took me a few hours to figure this out. Hope this helps some other unexperienced designer out there!

Requirements

  • Windows machine (Running Windows server 2016 or Windows 10). Theoretically works with Linux, but save yourself the headache and hours of debugging and stick with Windows if possible.
  • Visual studio 2019 with C++ Build tools (Add this package in the installer)
  • A clean install of Jenkins
  • Optional: Source control of your choosing. I won't be going over setting this up in this tutorial.

Setting up the Jenkins project

Start by creating a new freestyle project. After setting a name and clicking next, you will arrive at the main setup screen. If you’re using Source Control, add it under SCM settings. If not, you should add the project on your server’s hard drive and save the path to the project. For example, my path is “C:\Users\Win\Perforce\Feiko181353_BuildServer\Y2018C-Y1-DP-Team08\PlatformGameTemplate.uproject”

After this, toggle periodic builds and enter H/30 * * * * (You can change 30 to a number between 1 and 60) to create a build every 30 minutes. You can also setup a source control trigger, so a build starts after each push to the source control server.

Then go down and add 3 Windows Batch Command build steps:

“UNREAL INSTALL LOCATION \Engine\Binaries\DotNET\UnrealBuildTool.exe” -projectfiles -project=”PATH TO PROJECT” -game -rocket -progress

“UNREAL INSTALL LOCATION\Engine\Build\BatchFiles\RunUAT.bat” BuildCookRun -project=”PATH TO PROJECT” -noP4 -platform=Win64 -clientconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory=”BUILD SAVE PATH”

set “str=%~1” cd “BUILD SAVE PATH” “C:\Program Files\7-Zip\7z.exe” a %BUILD_NUMBER%.zip “BUILD SAVE PATH”

The last step is optional, it simply zips the build and renames it to the current build number.

Your eventual setup should look something like this:

“C:\Program Files\Epic Games\UE_4.21\Engine\Binaries\DotNET\UnrealBuildTool.exe” -projectfiles -project=”C:\Users\Win\Perforce\Feiko181353_BuildServer\Y2018C-Y1-DP-Team08\PlatformGameTemplate.uproject” -game -rocket -progress

“C:\Program Files\Epic Games\UE_4.21\Engine\Build\BatchFiles\RunUAT.bat” BuildCookRun -project=”C:\Users\Win\Perforce\Feiko181353_BuildServer\Y2018C-Y1-DP-Team08\PlatformGameTemplate.uproject” -noP4 -platform=Win64 -clientconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory=”C:\Users\Win\Google Drive\Team 8 Block C Shared Drive\Builds\Autobuilds”

set "str=%~1"

cd “C:\Users\Win\Google Drive\Team 8 Block C Shared Drive\Builds\Autobuilds”

“C:\Program Files\7-Zip\7z.exe” a Aztech_%BUILD_NUMBER%.zip “C:\Users\Win\Google Drive\Team 8 Block C Shared Drive\Builds\Autobuilds\WindowsNoEditor*”

If you have all of this, click save and try to create your first build. If the build fails to start, you incorrectly setup the paths or you installed Visual Studio incorrectly. If the build starts but it says “BUILD FAILED” in the log, there are errors in your Unreal project but your build server is working fine.

Another nice feature in Jenkins is the possibility to use pipeline scripts, allowing much more freedom in your jobs. If you have the scripts from this tutorial running, it will be fairly simple to migrate it to a pipeline job and there are many great tutorials out there to help you with this.