Jenkins Setup for Unreal Engine

Setting up Jenkins to work with Perforce and Unreal Engine

Thu, 06 Oct 2022

There a million tutorials already on how to set up Jenkins. This will be a quick one on how I get it set up locally to run unreal engine builds. If you already have jenkins installed or know how to set it up, here’s a tutorial on how to set up a build agent. For the purpose of this guide, the server will be our build agent

Like I said, I’m not going to reinvent the wheel, set up jenkins following their Installation Guide

Perforce

We will be using Perforce as our SCM for this guide. Once Jenkins is installed head over to Manage Jenkins -> Manage Plugins and inside the search box, search "Perforce". Download this plugin and restart jenkins

My depot type is stream and will be writing this guide with the assumption that yours will be as well.

Lets set up the pipeline. New Item -> Enter name -> Select Multibranch Pipeline and hit okay

You should be in the configure screen, if not, navigate to the pipeline you just created and hit Configure.

Scroll down to Branch Sources and click Add Source -> Helix Stream.

In git, a branch is represented by origin/reponame/feature/itemsystem for example. This same branch as a stream in perforce would be //repo_name/feature/item_system. In the include streams box you want to input a value similar to above. I want my game to build on any stream inside of my depot, I do that by entering in the value //edgemaul_legends/* or //edgemaul_legeds/.... I’m showing you the … format because you may see it being used by your server. For perforce, … is the same as *.

Optional

The default checkout settings for perforce will delete your intermediate folder which will cause your builds to start from scratch rather than be incremental. I chose to have jenkins to not delete any generated build files. In the future I may change this to do it for all streams except my release streams. For now, this is set up on all my streams.

If you’re following the steps from above, under Branch Sources click Advanced and under Populate options uncheck DELETE generated files

The next change is that I don’t like Jenkins to keep around streams that no longer exist on the server. If you don’t do this, all of your build history for streams that no longer on the server will persist. IF you want that, leave it alone. If you want something clean and concise thats relevant for only what you have, check this off

Orphaned Item Strategy -> Check Discard old items

Triggers

Perforce needs to be configured to trigger builds to Jenkins. You may need to alter the script that I’m providing if you’re not on a Windows OS.

  1. Generate a new Jenkins token. Click on your name on the top right of Jenkins, hit Configure and under Api Token click Add New Token. Save this value for later
  2. Open up your favorite text editor and paste this code in
curl --location --request POST "http://localhost:8080/p4/event" ^
--header "Content-Type:application/json" ^
--header "Authorization:Basic JENKINS_TOKEN ^
--data "{\"change\":%1,\"p4port\":\"localhost:1666\",\"event_type\":\"UPDATED\"}"

This is just a basic curl request. You can call this from anywhere that will allow you to make a URL request

  1. Replace http://localhost:8080 with your Jenkins URL. This is the default URL for a local install
  2. Replace JENKINS_TOKEN with the token from step 1
  3. Replace localhost:1666 with your Perforce Port(URL). This is the default URL for a local install
  4. Save this file to your p4root(the directory that your helix core server uses). For me thats C:\perforceroot. I created a folder for it and the file location of the file was **C:\perforceroot\scripts\Jenkins.bat**
  5. Next we will add this script to perforce and tell it to run it whenever a change is submitted to our game. Open a new cli window and type in p4 triggers. At the bottom of the file that pops up, enter this in

elg-build change-submit //edgemaul_legends/... "C:\perforce_root\scripts\jenkins.bat %change%"

  • elg-build = The name of this trigger. Must be unique amongst your servers triggers. Feel free to change it, mine is shorthand for my game (Edgemaul Legends Game).
  • change-submit = The action that will trigger the run of our Jenkins.bat script
  • //edgemaullegends/… = the streams that you want this to trigger on. Usually you want all streams to be built by Jenkins, so go with //yourdepot_name/…
  • “C:\perforce_root\scripts\jenkins.bat %change%” = The location of the script. The %change% will pass in the change number (similar to a sha in git) which will tell Jenkins what to build

Blue Ocean

Another optional feature is to install Blue Ocean. Its a nice easy to digest UI. You can do that by going to Manage Plugins again and install the Blue Ocean plugin. You don’t have to do this but I prefer it since it has each build step displayed beautifully in comparison to the default ui

Build Agent

For my setup I opted for a local install for now. This step should be done regardless of what build agent you’re using. For my guides, I set labels on my build agents so each agent will build only certain applications. In addition to that, Unreal Engine can only run 1 build at a time so you want to set the max number of jobs your agent can run to 1.

  1. Navigate to Manage Jenkins -> Manage Nodes and Clouds
  2. Click your agent name. For me, its Built-In Node
  3. Click Configure
  4. Set Number of executors to 1
  5. Set Labels to UnrealEngineWin
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