GitLab Tutorial - Part 2 - Setting Up GitLab CI (Continuous Integration)
8K views
Feb 15, 2023
Full course available at https://www.codereviewvideos.com/course/your-own-private-github In the previous video we installed GitLab CE (Community Edition) using the Omnibus installer. In doing so, GitLab CI (Continuous Integration) was also installed for us. However, GitLab CI is disabled by default. Thankfully, enabling GitLab CI is a fairly straightforward exercise. At its simplest, it's a case of editing a config file (/etc/gitlab/gitlab.rb) and running the sudo gitlab-ctl reconfigure command a couple of times.
View Video Transcript
0:00
Hi this is Chris from CodeReviewVideos and in this video we're going to be installing GitLab CI
0:04
into our existing GitLab instance. We're going to have them both running on the same server
0:09
that is to say our GitLab CI and also our GitLab are going to be on the same IP address. So what
0:15
you're seeing in the background here is I'm editing the host name and also the hosts file
0:20
just to make sure that they can talk to each other via DNS name. Even though it's the same machine
0:25
this is pretty much required so the reason that we're installing gitlab ci in case you're kind of
0:32
unsure as to what we use ci or continuous integration for is effectively it encourages
0:38
developers to take note of the quality of a project because even if they don't have the
0:45
test suite set up to run locally on their machine the idea of having a continuous integration server
0:51
is when the code is pushed up, the tests are automatically run in the background
0:56
and the developer doesn't really need to think about it. Even though obviously they should have them running
1:02
on the local machine, in many projects from personal experience, getting that into that mindset is more difficult
1:09
if you don have the visibility to begin with So if you can show people that when they pushing that code up it breaking existing functionality it does encourage them then to actually take well start using the test suite so it kind of a win and as we installed the omnibus edition of gitlab we
1:27
already have gitlab ci built in the functionality is already built in so it's just a case of
1:32
enabling it so there's really no excuses not to use it if you're wondering how to get it installed
1:37
onto a separate box so if you want to use gitlab on one server and gitlab ci on another you can
1:45
just go ahead and install the same package on another server and then just go ahead and only
1:51
enable the ci on one and gitlab on the other but it's it's in the documentation so it's not
1:57
particularly difficult to follow so as you can see once we've made the necessary changes to the
2:01
gitlab config file we just need to do a reconfigure and let it do its thing it'll go off in the
2:07
background and enable the new features and whatnot and then they'll be available for us
2:11
the only thing that um is kind of different here is because i'm running it on a virtual machine
2:17
and that machine only sits on my network and it's not on the internet then i'm adding entries to my
2:23
host file to make it so that i can access it using its dns name as opposed to and you can see there
2:28
that both on dot 22 but that so that i don need to use the ip addressing and also then i can connect to that machine using its name and whatnot It just makes it easier all around But if you out on the internet then obviously you would use the real DNS name
2:43
The way that GitLab CI is going to talk back to GitLab, even though it's on the same server, is via OAuth2
2:49
We're going to set that up in a sec. As you'll see, we're going to create the application ID and the client secret
2:54
and then we're going to pop that in and everything should go through as expected. but of course if we're using OAuth 2 then we really need to go ahead and enable SSL
3:03
I'm not doing that in this video but I will link to how to do so in the show notes
3:07
but be aware that if you do this using GitLab, so enabling SSL on GitLab
3:13
you need a two-year certificate, a two-year SSL certificate. You can self-sign, do it whichever way you want
3:20
but just be aware that you do need it to be at least two years. Probably the trickiest piece in the whole puzzle
3:26
even though it's not that particularly difficult is coming up in a sec and that's to know whether
3:30
to use the gitlab or the gitlab ci url when we're entering in some compig as you'll see in a sec
3:37
this is the bit that caught me out the most pretty much the rest of it is just copy and paste but
3:42
like as you'll see here you're supposed to use the gitlab server in the url not the gitlab ci
3:47
i pretty sure the first few times i went through this this this confused me because you providing the compig to GitLab CI so it already knows about itself So obviously you not going to tell it the URL to itself
3:57
You say this is the URL to the GitLab server and this is the config for the GitLab underscore CI
4:04
So hopefully that does make it a little bit more self-explanatory because, as I say, the first few times I went through doing this, I kept putting in the wrong thing
4:13
And you only find out after you've done a reconfigure. It's not the end of the world, of course, but it is one of those things where you're just like
4:19
oh, for God's sake, I wish I knew what I was doing. So hopefully, yeah, that'll save you that in terms of headache
4:26
And then after that, really, it's pretty much plain sailing. You can see in there that there's all the other config
4:31
and that's where you would put in the SSL stuff. As I say, we'll link to that in the show notes
4:35
But again, it's just a reconfigure, and then we should be good. And after this, really, the only thing that we need to do is add in our runners
4:42
So those are the things that are going to listen for the pushes, the Git pushes up to the server
4:48
And then effectively they will run the test suite for any project that they configured for
4:55
Configuring the runners will be in the next video. Not particularly difficult
4:59
Again, there's one little bit that will perhaps catch you out. But yeah, it's not difficult at all
5:04
You don't need exactly big hardware for it either. So it is quite economical