Jenkins and UE4

NOTE: This guide assumes you already have a machine with Jenkins on it.

 

Prerequisites

  • Windows machine (or you can use a Windows agent)
  • UE4 and Jenkins installed
  • Patience

 

  1. Create a new job as a freestyle project.
  2. Choose "This project is parameterized."
  3. Add 1 choice parameter and 2 string parameters.
  4. Fill in the content as follows.
    ==== Choice Parameter ====
    
    == Name ==
    
    BUILD_CONFIGURATION
    
    == Choices ==
    
    Development
    
    Shipping
    
    Test
    
    DebugGame
    
    == Description ==
    
    Development = This configuration is equivalent to Release. Unreal Editor uses the Development configuration by default. Compiling your project using the Development configuration enables you to see code changes made to your project reflected in the editor.
    
    Shipping =  This is the configuration for optimal performance and shipping your game. This configuration strips out console commands, stats, and profiling tools.
    
    Test =  This configuration is the Shipping configuration, but with some console commands, stats, and profiling tools enabled.
    
    DebugGame = This configuration builds the engine as optimized, but leaves the game code debuggable. This configuration is ideal for debugging only game modules.
    
    

    ==== String Parameter ==== == Name == ENGINE_PATH == Default Value == C:\Program Files\Epic Games\UE_4.25\ == Description == The path for the engine install.

    ==== String Parameter == == Name == PROJECT_NAME == Default Value == MyProject == Description == This is the name of your project and the folder that it’s in. (they need to match)

  5. Set up your Source Control Management. We use PlasticSCM (requires you to install a plugin).
  6. Check Poll SCM and put @hourly
  7. Under Build add 3 Execute Windows batch command.
    FOR /d /r . %%d IN (Intermediate) DO @IF EXIST "%%d" rd /s /q "%%d"
    
    FOR /d /r . %%d IN (Binaries) DO @IF EXIST "%%d" rd /s /q "%%d"
    
    

    @RD /S /Q “Build” @RD /S /Q “Saved” @RD /S /Q “.vs” del “%PROJECT_NAME%.sln” /s /f /q

    ===============================

    “%ENGINE_PATH%Engine\Binaries\DotNET\UnrealBuildTool.exe” -projectfiles -project="%WORKSPACE%%PROJECT_NAME%.uproject" -game -rocket -progress “%ENGINE_PATH%Engine\Binaries\DotNET\UnrealBuildTool.exe” %PROJECT_NAME% %BUILD_CONFIGURATION% Win64 -project="%WORKSPACE%/%PROJECT_NAME%.uproject" -rocket -editorrecompile -progress -noubtmakefiles -NoHotReloadFromIDE -2019

    ===============================

    “%ENGINE_PATH%Engine\Build\BatchFiles\RunUAT.bat” BuildCookRun -project="%WORKSPACE%%PROJECT_NAME%.uproject" -noP4 -platform=Win64 -clientconfig=%BUILD_CONFIGURATION% -cook -numcookerstospawn=8 -compressed -EncryptIniFiles -ForDistribution -allmaps -build -stage -pak -prereqs -package -archive -archivedirectory="%WORKSPACE%/Saved/Builds"

  8. Done.

 

If you're using the source build then add -client before -build to build the Client Target otherwise it'll build as <Platform>NoEditor.

 

A dedicated server build requires a source build on the Jenkins machine. NOTE: At the time of writing this I haven't got Shipping builds working with Steam and dedicated server. The Steam API doesn't initialize for some reason.

// Windows Server

"C:\UE4Source\Engine\Binaries\DotNET\UnrealBuildTool.exe" %PROJECT_NAME% %BUILD_CONFIGURATION% Win64 -projectfiles -project="%WORKSPACE%/%PROJECT_NAME%.uproject" -rocket -progress -noubtmakefiles -NoHotReloadFromIDE -2019 -TargetType=Server

“C:\UE4Source\Engine\Build\BatchFiles\RunUAT.bat” BuildCookRun -project="%WORKSPACE%%PROJECT_NAME%.uproject" -noP4 -platform=Win64 -build -clientconfig=%BUILD_CONFIGURATION% -serverconfig=%BUILD_CONFIGURATION% -cook -stage -pak -generatechunks -EncryptIniFiles -server -serverplatform=Win64 -noclient -archive -archivedirectory="%WORKSPACE%/Saved/Builds"

// Linux Server “C:\UE4Source\Engine\Binaries\DotNET\UnrealBuildTool.exe” %PROJECT_NAME% %BUILD_CONFIGURATION% Linux -projectfiles -project="%WORKSPACE%/%PROJECT_NAME%.uproject" -rocket -progress -noubtmakefiles -NoHotReloadFromIDE -2019 -TargetType=Server

“C:\UE4Source\Engine\Build\BatchFiles\RunUAT.bat” BuildCookRun -project="%WORKSPACE%%PROJECT_NAME%.uproject" -noP4 -platform=Linux -build -clientconfig=%BUILD_CONFIGURATION% -serverconfig=%BUILD_CONFIGURATION% -cook -stage -pak -generatechunks -EncryptIniFiles -server -serverplatform=Linux -noclient -archive -archivedirectory="%WORKSPACE%/Saved/Builds"

 

I also recently set up Jenkins for my plugins so they get built every time I do a commit etc.

"C:\Program Files\Epic Games\UE_4.25\Engine\Build\BatchFiles\RunUAT.bat" BuildPlugin -Plugin="%WORKSPACE%\PLUGINNAMEHERE.uplugin" -Package="%WORKSPACE%\Packaged" -Rocket -VS2019 -TargetPlatforms=Win64

 

To push the build to Steam do something like this using the "Conditional step" plugin on Jenkins

C:\SteamTools\steamcmd.exe +login USERNAME PASSWORD +run_app_build -desc "cs:%PLASTICSCM_CHANGESET_ID% bn:%BUILD_NUMBER%" C:\SteamTools\tools\ContentBuilder\scripts\app_x.vdf +quit

 

Last notes

Here are some other resources for this.

 

until next time