Unity has a reputation for being a beginner friendly engine. It does a lot of things out of the box for you. Building and deploying your app is pretty simple if you’re a solo dev just trying to get your game onto a device. However, Unity doesn’t make it easy to set up more professional build and deployment workflows, like multi-platform builds, command line building, or CI/CD pipelines. Here you will find a demo of the tooling that Electric Pipelines can set up to make your builds easier. We offer hand crafted dev ops for game companies.
This demo can be found in video form.
For this demo, we have a Unity game. We will be deploying it Android, and building the backend server on Linux and Windows. We will be building and deploying these both manually in the editor and through a build pipeline we’ve set up on Jenkins.
For multiplatform games, Unity require you to switch configuration before you build another platform. This eats up a lot of time for larger projects.
To get around that, you can write your own scripts to build your project for different configurations. We have set up scripts to build each individual platform, and a few for combinations.
Now, you can use menu options in the editor to build each individual platform.
Building from the command line
Unity lets you do almost anything you can do in the editor from the command line. There is a catch: you have to write scripts for all of it. With the scripts we set up earlier, we can build our game from the command line. In the example below, we will call Unity from the command line and tell it to run our build method, BuildPlayerExample.AndroidBuild, on the project found in the folder BomberPrototypeUnity. You can find the full documentation on Unity command line builds here.
CI/CD pipeline in Jenkins tour
Now that we have command line building working, we have all of the tools we need for setting up a CI/CI pipeline.
We’ve set up a CI/CD pipeline in Jenkins that can build each platform. Jenkins will set up build agents that will use something similar to the command line option above to build on each platform.
We can trigger builds for each platform using git tags. You can tag each commit in git with different build actions. In the example below, you can see that we’ve tagged our commits to build Android, Linux, Windows, Headless servers, and iOS. You have a lot of flexibilty on what platforms you build and how long your build is going to take.
Once you kick off a build, you can track the build progress in Jenkins. In this demo, we set up a build that would publish to AppCenter at the end, so that beta-testers would have access.