UE4/UE5 Jenkinsfile Example - Basic

Quick example for a UE4/UE5 Jenkinsfile build

Sun, 10 Jul 2022

This is just a basic example of a Jenkinsfile that builds a UE4 and UE5 game client. If you want more details on how to set up Jenkins and a build PC to automate your game builds check out this link to the series where I went over this.

pipeline {
    agent { label 'UnrealEngineWin' }
    environment {
        WIN_ENGINE_DIRECTORY     = 'C:\\Projects\\UnrealEngine\\Engine'
        PROJECT_NAME             =  'MyUnrealGame'

    options {
        timeout(time: 60, unit: 'MINUTES')

    stages {
        stage('Windows') {
            steps {
                    echo 'Building Windows Client'
                    script {
                        if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME.contains('rel_')) {
                            bat "$WIN_ENGINE_DIRECTORY\\Build\\BatchFiles\\RunUAT.bat BuildCookRun -nocompileeditor -installed -nop4 -project=$WORKSPACE\\$PROJECT_NAME.uproject -cook -stage -archive -archivedirectory=$WORKSPACE\\dist -package -ue4exe=$WIN_ENGINE_DIRECTORY\\Binaries\\Win64\\UE4Editor-Cmd.exe -ddc=DerivedDataBackendGraph -pak -prereqs -distribution -nodebuginfo -targetplatform=Win64 -build -target=$PROJECT_NAME -clientconfig=Shipping -utf8output"
                        else {
                            bat "$WIN_ENGINE_DIRECTORY\\Build\\BatchFiles\\RunUAT.bat BuildCookRun -nocompileeditor -installed -nop4 -project=$WORKSPACE\\$PROJECT_NAME.uproject -cook -stage -archive -archivedirectory=$WORKSPACE\\dist -package -ue4exe=$WIN_ENGINE_DIRECTORY\\Binaries\\Win64\\UE4Editor-Cmd.exe -ddc=DerivedDataBackendGraph -pak -prereqs -distribution -nodebuginfo -targetplatform=Win64 -build -target=$PROJECT_NAME -clientconfig=Development -utf8output"

Lets do a quick breakdown of each section


This section makes sure my gmae is only built by a Jenkins agent that has the label UnrealEngineWin. You can create your own label, I used this one because I have a Mac Agent with Unreal on it


We have variables here that we use often throughout the file. I put these in here to make this script adaptable in the event that I want to use a different engine version or if I want to copy and paste this to another project. All I have to do is just update the associated values and it should just work!


Sometimes the automation tool that we use to build our game can get stuck. This is completely optional, in my case I know that if my build is taking longer then an hour something went wrong so I set it to 60 minutes to cancel the build

Windows Client

This is where the magic happens. We are calling the Unreal Automation Tool to help us build our game. This tool is the same tool that the engine uses when you build it via the UI. Lets break it down

This section is to allow us to build a production or dev version of the client. The content inside the if/else is similar. The only difference is the clientconfig. Having a vlaue of Shipping will strip debug symbols that would be found in the value of Development as well as optimize the game.

if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME.contains('rel_')) {
   ...build prod
else {
   ...build dev

Location of the batch script being ran -“$WINENGINEDIRECTORY\Build\BatchFiles\RunUAT.bat

The main command we are calling from the RunUAT batch script - BuildCookRun

Doesnt compile the editor(or editor plugins) in the build phase - nocompileeditor

We are doing a build that does not require the client to have unreal engine -installed

Files produced are ignored by perforce -nop4

Project location -project=$WORKSPACE\$PROJECT_NAME.uproject

Build, cook and stage all game assets -build -cook -stage

We want to archive the build -archive Directory where our archived copy of the game is going-archivedirectory=$WORKSPACE\dist

Package the game for distribution -package

Location of the ue4 executable -ue4exe=$WINENGINEDIRECTORY\Binaries\Win64\UE4Editor-Cmd.exe

Platform(s) to build -targetplatform=Win64

Project to build -target=$PROJECT_NAME

Buy Me A CoffeeDigitalOcean Referral Badge
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.