Installing Jenkins with Unity3D 2019 on Windows and make a first build, with GitHub and SSH
Installing Jenkins with Unity3D 2019 on Windows and make a first build, with GitHub and SSH
In this instructional video I am installing Jenkins on a Windows machine for use with Unity3D 2019, and make a simple pipeline Unity3D build with it. Further more I show you how to use GitHub+SSH with Jenkins.
Edit 2021: If you need help, head over to my discord at https://discord.gg/UteZv8zJDt on the channel ‘game-dev-talk’.
If you want to spend less time building and fixing bugs you want to setup a build/test pipeline for your Unity3D projects. I did this with Jenkins because I liked to do this ‘low budget’ and ‘start small’. Alternatives are Unity Cloud or Azure DevOps. Edit: I have moved on to Azure DevOps myself, because the interface and self hosted stuff is way more easy to use and maintain (then Jenkins). I have also a video on this setup over on • How to set up an Azure DevOps Unity3D…
00:00 Install Jenkins 03:28 Customize Jenkins 04:42 Connect GitHub 07:13 Install a GIT client 09:00 Show Jenkins where to find Unity 09:45 Create a pipeline with a Unity build 12:30 Explanation of the build output 13:06 Unity build script details
Content
0.5 -> Lets start by downloading Jenkins for Windows.
4.16 -> I’m going to install Jenkins on my own development
system.
7.94 -> It’s a lot easier to setup Unity 3D this way, but the downside is that I can’t
access it when I’m not at home.
15.28 -> Jenkins is available for a lot of platforms,
so if you ever want to migrate you can go
20.28 -> anywhere. As long as the Unity3D editor is
allowed to run on that platform of course.
30.08 -> Jenkins will install a service on your machine
that will stay available in the background.
34.16 -> This service then hosts a website that is
the interface to your build automation.
39.94 -> As with other automation tools, it needs space
to store and execute builds. I have changed
44.54 -> these paths to look at my data disks, if you
ever wonder why that is.
49.2 -> Now we need to prove to the system we are
the sys admin, for this purpose there is a
53.4 -> local file with the password in it. After
we have proven to be the sys admin, we can
57.56 -> continue with the installation.
65.02 -> In this phase of the installation we can select
the main components we need for Jenkins to
68.62 -> have. Don’t worry, you can change these
later-on though the Jenkins config.
77.6 -> If you don’t know what you are doing, just
add things only. And read the descriptive tags.
89.96 -> I know Jenkins is usable for many things,
so I install the things that are likely to
93.94 -> me that I need them sometime in the future.
115 -> Here we need to select the GitHub source option,
because this demo is also about enabling SSH
119.32 -> for a GitHub project.
135.48 -> I don’t know what I need for user management,
but I do know I want it to be simple so just
140.86 -> role based authorization for me.
155.16 -> There is a lot of cool stuff available for
Jenkins.
165.02 -> Well, I definitely want to be able to change
the UI language because it will enable the
169.04 -> system language by default and, on my system
that is Dutch.
182.98 -> Some waiting later and Jenkins is almost ready.
189.7 -> Ah, here I can create my own user with admin
rights.
199.74 -> Remember this address, it is the interface
url.
207.62 -> And lets start by changing the UI language
to English.
229.32 -> Now I have to setup the
Unity3D and Git plugins.
237.64 -> I go to ‘manage Jenkins’ and ‘manage plugins’.
244.28 -> GitHub integration is already installed,
but I still need to get the Unity3D
258.78 -> The Unity3D plugin is an open source project
over at GitHub. It is a bit dated and there
263.66 -> is also no good documentation for it. Hence
this video tutorial. But it gets the job done.
271.94 -> I go to ‘manage Jenkins’ again but this
time to ‘Tool configuration’.
278.28 -> Hmm, the git install isn’t looking well.
Okay, lets fix something else first. I need
284.3 -> to add an SSH key to Jenkins and GitHub.
290.04 -> On the way to GitHub I admire my attempt at
the GlobalGameJam 2020.
296.34 -> Lets move on. I go to my GitHub account to
the settings. There is a tab here with SSH
301.58 -> and GPG keys, that’s the place to store
my SSH key.
324.32 -> But I don’t have an SSH key yet, so lets
generate one. For this I can just start the
330.36 -> command line and call a tool to make the required
files.
333.54 -> You all probably have this tool on your system.
342.52 -> The generated file will be in the base of
my profile, next to all folders like my documents.
347.12 -> Just press enter and the tool will do its
work.
354.7 -> And here are my SSH keypair files. So I select
the one starting with ssh-rsa and copy it
361.78 -> over to GitHub.
365.98 -> Done
367.22 -> Lets see… now I need to add the other
part to Jenkins.
378.76 -> At Credentials I add a new account with the
login type SSH key.
383.36 -> The benefit of SSH keys for me is that I can
track the usage of these keys and easily revoke
387.74 -> permissions if I want to.
412.32 -> Names names and names…
414.44 -> And here I finally
can add the private part of the SSH key.
430.14 -> Okay, with that done I can go back to the
Git tool setup.
441.94 -> For sure it is not okay, because there is
red text everywhere. Okey, I need to repair
446.68 -> the Git client. Apparently there is no client
installed on this machine so I have to get one.
455.98 -> Just the default open source Git client for
me.
485.86 -> And as with all cool tools, It wants to integrate
with everything and has a lot of options to
491.48 -> configure. I’m feeling an kung fu admin
already.
499.86 -> Notepad++ for sure.
526.68 -> Aaaand finally installing.
535.86 -> This will probably work fine, I’m going
to ignore these red warnings from now on.
541.9 -> And now to configure Unity3D.
545.32 -> I have meditated
2 hours on how to get this working
548.6 -> (as you can see on the system clock)
550.34 -> and then suddenly
It came to me.
552.02 -> Go to the Unity hub and to the installs
section and there you can easily
555.06 -> find the paths of your Unity installations.
573.9 -> However pay attention when setting the paths.
You need to point at the root folder,
578.78 -> so one above the Editor folder.
581.74 -> Aaand on the actual build pipeline.
589.86 -> Lets start with creating a simple project.
595.04 -> I am going to use one of my existing Unity3D
codebases to hook it up to the automated build.
601.66 -> ‘Find the Gnome’ is an old multi-platform project
of mine, so it is well suited for this purpose.
614.36 -> Okay, this is it. The build pipe.
616.66 -> I was fooled by the looks but don’t be,
you can get magic done on this page.
621.6 -> Be sure to check the discard builds because
otherwise your system will clutter up fast.
626.78 -> I am going to add an SSH coupling to my
github project for this build.
646.94 -> And because of my branching strategy
I have to point to the steam build.
652.48 -> I probably want to add automatic build
triggers later on but
656.3 -> for now I am going to trigger
the builds manually.
661.28 -> I definitely want to abort the build if it
takes too long because this build will start
665.5 -> some Unity3D processes in the background that
aren’t visible and if they hangup
669.38 -> I have no idea on what happened.
685.04 -> For help on the environment variables you
can look over at the Jenkins website,
690.14 -> I for instance made a typo in the build
name. Can you find it?
704.5 -> I did not know the build button can be used
multiple times to chain build commands.
715.94 -> Lets start with adding a normal
Unity3D build first.
726.7 -> The command line arguments to Unity3D are
available over at the Unity website.
731.44 -> The main thing is a class you reference in
which you can control what to do and
735.98 -> if Unity succeeded.
738.04 -> I will go into detail about this class after
saving.
751.04 -> But first I will show you the actual building.
766.96 -> Okay, as you can see the output of Unity3D
is visible in the background,
770.68 -> and in the folder you see a Windows build appearing.
777.88 -> On that specific build my script
wasn’t fully working yet
780.6 -> so hence the .exe is missing on the executable.
787.28 -> This Is that Unity3D script I referenced.
789.98 -> The main thing you need to tell Unity3D
is the scenes you want to build.
793.48 -> But you can add other instructions
like pre-packaging and specific targets.
798.12 -> You could even do testing here and signal ‘failed’
when things don’t work out as planned.
804.04 -> You can find the script I used
in the description
806.58 -> and some more sources on Unity3D
builds with Jenkins there.
811.54 -> Thank you for watching and I wish you luck
on your Unity3D with Jenkins project!