
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Manage Docker images with Cloud Build and Artifact Registry
/ 30
Automate Builds with Trigger
/ 30
Test your Build Changes
/ 40
In this lab, you will build a continuous integration pipeline using GitHub, Cloud Build, Build triggers, and Artifact Registry.
In this lab, you will learn how to perform the following tasks:
If you do not already have a GitHub account, you will need to create a GitHub account
Recommendations
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
First, you will create a Git repository using the GitHub. This Git repository will be used to store your source code. Eventually, you will create a build trigger that starts a continuous integration pipeline when code is pushed to it.
Press Enter
to accept the default options. Read the instructions in the CLI tool to log in through the GitHub website.
If you have logged in successfully, this should output your GitHub username.
GITHUB_USERNAME
variableIf you have successfully created the variable, this should output your GitHub username.
This command creates a git user for your Cloud Shell terminal.
gcp-course
:devops-repo
. Change to that folder:You need some source code to manage. So, you will create a simple Python Flask web application. The application will be only slightly better than "hello world", but it will be good enough to test the pipeline you will build.
main.py
and press Enter.devops-repo
folder.templates
and press Enter.templates
folder and create a new file called layout.html
.Also in the templates folder, add another new file called index.html
.
Add the following code and save the file as you did before:
In Python, application prerequisites are managed using pip. Now you will add a file that lists the requirements for this application.
In the devops-repo folder (not the templates folder), create a New File and add the following to that file and save it as requirements.txt
:
The first step to using Docker is to create a file called Dockerfile. This file defines how a Docker container is constructed. You will do that now.
The file Dockerfile is used to define how the container is built.
This is the base image. You could choose many base images. In this case, you are using one with Python already installed on it.
These lines copy the source code from the current folder into the /app folder in the container image.
This uses pip to install the requirements of the Python application into the container. Gunicorn is a Python web server that will be used to run the web app.
The environment variable sets the port that the application will run on (in this case, 80). The last line runs the web app using the gunicorn web server.
The Docker image has to be built and then stored somewhere. You will use Cloud Build and Artifact Registry.
Notice the environment variable in the command. The image will be stored in Artifact Registry.
On the Google Cloud console title bar, type Artifact Registry in the Search field, then click Artifact Registry in the search results.
Click on the Pin icon next to Artifact Registry.
Click devops-repo.
Click devops-image. Your image should be listed.
On the Google Cloud console title bar, type Cloud Build in the Search field, then click Cloud Build in the search results.
Click on the Pin icon next to Cloud Build.
Your build should be listed in the history.
You will now try running this image from a Compute Engine virtual machine.
On the Navigation menu, click Compute Engine > VM Instance.
Click Create Instance to create a VM.
On the Create an instance page, specify the following, and leave the remaining settings as their defaults:
Property | Value |
---|---|
OS and storage > Container | Click DEPLOY CONTAINER |
Container image | ' |
Networking > Firewall | Allow HTTP traffic |
Click Create.
Once the VM starts, click the VM's external IP address. A browser tab opens and the page displays Hello DevOps Fans.
Click Check my progress to verify the objective.
On the Navigation menu, click Cloud Build. The Build history page should open, and one or more builds should be in your history.
Click Settings.
From Service account dropdown, select
Enable the Set as Preferred Service Account option. Set the status of the Cloud Build
service to Enabled.
Go to Triggers in the left navigation and click Create trigger .
Specify the following:
Name: devops-trigger
Region:
For Repository, click Connect new repopository
Branch: .*(any branch)
Configuration Type: Cloud Build configuration file (yaml or json)
Location: Inline
Click Open Editor and replace the code with the code mentioned below and click Done.
For Service account select the service account starting with your project-id that look similar to (
To test the trigger, click Run and then Run trigger.
Click the History link and you should see a build running. Wait for the build to finish, and then click the link to it to see its details.
Scroll down and look at the logs. The output of the build here is what you would have seen if you were running it on your machine.
Return to the Artifact Registry service. You should see a new image in the devops-repo > devops-image folder.
Return to the Cloud Shell Code Editor. Find the file main.py
in the gcp-course/devops-repo
folder.
In the main() function, change the title property to "Hello Build Trigger."
as shown below:
Click Check my progress to verify the objective.
When the build completes, click on it to see its details.
Click Execution Details,
Click the Image name. This redirects you to the image page in Artifact Registry.
At the top of the pane, click Copy path next to the image name. You will need this for the next steps. The format will look as follows.
Go to the Compute Engine service. As you did earlier, create a new virtual machine to test this image. Click DEPLOY CONTAINER and paste the image you just copied.
Select Allow HTTP traffic.
When the machine is created, test your change by making a request to the VM's external IP address in your browser. Your new message should be displayed.
Click Check my progress to verify the objective.
In this lab, you built a continuous integration pipeline using the GitHub, Cloud Build, Build triggers, and Artifact Registry.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one