Chris Blackden: Hello, today we're going to go over how to
set up a cloud build CICD pipeline using GCP cloud build and
cloud source repositories. So to start off, I have a cloud
source repository here on GCP. And it's got three files in
it. The first is quickstart.sh. This is just simple
HelloWorld. Next is the Docker file, which we're going to
use to build our container. And this is just taking Alpine,
copying the Quickstart shell script over and then running
it. And lastly, I have cloud build dot YAML. This is going
to be the basis for my pipeline. Each one of these steps is
going to become a build step later on. So on line two we
have cloud builders Docker. This is a pre built Docker
container with all of the tools necessary to run a Docker
build. And there are several of these depending on which
language and version you need to use, I will throw a link to
the GitHub repository where these are stored into the snip
description. But that container is going to take the Docker
build commands as an argument. So in this case, on line
three, build dash t with our repository name, and then it's
going to generate a Docker image and upload it to GCR, which
is their on line five. So now that that's setup, let's go
over to cloud build. Okay, I'm here in cloud build and the
first thing I want to do is go under triggers. And let's go
over here to connect a repository for a moment. You can see
that we have a few options here to connect Bitbucket or
GitHub or use a cloud source repository natively. Just so
you know, some of these are still in beta at the time of
this recording, which is why we're using cloud source
repository. But it is possible to do this through GitHub or
Bitbucket, as well. Let's go ahead and click here to create
a trigger. Now, if we wanted to go back to the triggers
page, and click on Create trigger at the top of the screen
here, it would bring us to the same spot. But let's go ahead
and select our repository. We will call this trigger "Hello
trigger." And we can leave the description the same what
this is going to do is it's going to detect a push from any
branch and use that to trigger our build. So if we look a
little bit here under trigger type, that's where we see
we're looking for a branch under branch regex. We're looking
that's a regex we can use for the branch naming convention.
So if you have feature or bug fix in your branch names, you
can filter those out as well and only build those. And then
we're going to scroll down a little bit and under build a
configuration file, we're going to use that and select cloud
build dot YAML, which lives at the root of our repository.
And we also have the ability to add some more variables into
here, but we're going to skip that because this is just a
demo. Let's go ahead and create that trigger. And we see it
here under our active repository triggers, we can go ahead
and run it directly from here. And let's go ahead and click
Show, it will take us over to the build itself, under cloud
build. All right, our build is successful. And we have the
logs down here to confirm that. So now our Docker container
is built. And we can go back to our build triggers. And we
if we enable or disable the trigger here that will control
whether the build runs in the first place. Alright, that's
it. Thank you for watching.