Game Tech Tutorial
Published in

Game Tech Tutorial

How to Reduce Unity build times for Jenkins? (CI/CD: Part 3)

A complete tutorial to improve Unity build times for your game projects and CI/CD on Jenkins.

Unity is an easy-to-use tool to simplify and speed up game development, but building a large Unity project can be a pain to waste your time.

Suppose you want to make a few small changes to your game, but it takes more than an hour to build and test the new features.

What …more than 1 hour? It sounds crazy, right?

I feel so surprised the first time I figured out the cause of this problem was Unity.

After doing some research, I discovered Unity imports all libraries and compresses game resources under the Library folder when you open the project for the first time, build games, or switch platforms.

If you have a large size of game resources and tons of libraries, your building time will become longer than expected.

This tutorial is a walkthrough of several points you can improve the build times of your Unity project and CI/CD infrastructure using Jenkins.

What you will learn

  • What happens when building Unity games?
  • How to optimize Unity build times?
  • How to improve build times for Jenkins?

What happens when building Unity games?

If you dive into the build logs, you can see Unity will start to initial assets to import all packages, libraries, and resources by creating a Library folder while building your games.


  • Building Unity Game for Android usually takes around 10–20 mins depending on the resources you have.
  • While building IOS will take even longer than Android because IOS requires exporting XCode Project, Build, and Archive to finish the build. Even if you have a few resources, this will still take around 30 mins to be done.

How to optimize Unity build times?

Since the Library folder is the cause of this issue, it can be predicted that Caching is the best solution.

You can cache it locally or on a server to optimize Unity build times.

  • Cache Library Folder
  • Shared Cache Server

Caching Library in the local folder is quite simple. Every time you build in Jenkins’s pipeline, you need to keep the previous Library folders. This is a common approach in Github Action/GitLab as you can find it in its pipeline.

- uses: actions/cache@v1.1.0
path: path/to/your/project/Library
key: Library-YourProjectName-TargetPlatform
restore-keys: |

However, Caching Library Folder at local on Jenkins may cause some weird problems. If you update some libraries or resources, Jenkins may have libraries or resources inconsistent problems with your local environment.

It means when you make some changes to the game project which does not take effect in the built file on Jenkins but your local build is fine.

One solution to this problem is to clean it up and rebuild it on Jenkins, but this will take you lots of time to figure out.

Fortunately, I found that Unity provides a Cache Server called Unity Accelerator that can cache Library folders for libraries and game resources which means you can rely on it to optimize the building time for Jenkins or your developing environment.


You can also apply other approaches to optimize build times like deleting unused packages and resources, downsizing textures or images, downsampling audio files, or even separating resources and codes. The purpose is to reduce the size of the Library folder and resources.

What is Unity Accelerator?

The Unity Accelerator is a caching proxy agent that can cache your assets like Library Folder to reduce iteration time when importing your game project for the first time or switching platforms.

Unity uses a local cache Library Folder, by default. If you work in a team, it might be beneficial to use Unity Accelerator, which shares the Asset Cache across your LAN.

Then let’s download, install, and set up Unity Accelerator for Jenkins.

Download an Install Unity Accelerator

Download Unity Accelerator:

Once you install Accelerator, you need to set up Unity Editor on your Jenkins as shown below.

Set up Unity Accelerator:

  1. In the Unity Editor, select Edit > Project Settings… (Windows) or Unity > Project Settings… (OSX).
  2. Select Editor from the left menu.
  3. Under the Cache Server section, set Mode to Enabled.
  4. Fill in the IP address with Accelerator’s IP address and port at 10080


5. Press the Check Connection button to test connectivity.

Finally, let’s put it together with Jenkins.

How to improve build times for Jenkins?

You can set up a cache server for your Jenkins Servers or CI/CD backends to shorten the build times.

In order to demonstrate how it works, we will use the Master and Slave architecture of Jenkins to integrate with a Cache Server (Unity Accelerator).

  • Cache Server (Unity Accelerator) can share copies of imported library folders to reduce the building time for master and slave nodes.
  • When a developer pushed any changes to Github, Github will send an event to Master Nodes via Amazon Route 53.
  • Then Master nodes can dispatch jobs to slave nodes by assigning the same label or different labels in the pipeline.
  • If one of the Slave nodes has built and uploaded cached files to Cache Server, other nodes can benefit from the Cache Server by downloading the copies of the Library to reduce the build times.


In my experience, using a cache server reduces build times by approximately three times.

Congregations, you have learned how to optimize the build times for your Unity project on the local environment and Jenkins backends.

Hope this tutorial is helpful to speed up your workflow so that you can focus on creating new features for games but not on dumb work.

If you liked this story, please show your support by 👏 this story or subscribe to our email to get the latest tutorials in the future.

Thank you for reading!

Related posts:

You might be interested in



We aim to save you time by offering highly technical tutorials and sharing our expertise, allowing you to concentrate on creating engaging game features rather than dealing with backend management or the burden of dump work.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eric Wei

Senior Full Stack Engineer & Solution architecture | AWS, GCP, Azure | Cloud, Unity Game Development, SDK, DevOps, and more.