0
0
GCPcloud~30 mins

Cloud Build for CI/CD in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Cloud Build for CI/CD
📖 Scenario: You work as a developer in a team that wants to automate the process of building and testing their application code whenever changes are made. Your team uses Google Cloud Platform (GCP) and wants to use Cloud Build to create a simple Continuous Integration/Continuous Deployment (CI/CD) pipeline.This project will guide you through setting up a basic Cloud Build configuration file that builds a Docker image and runs tests automatically.
🎯 Goal: Build a Cloud Build configuration file (cloudbuild.yaml) that defines steps to build a Docker image from source code, run tests, and push the image to Google Container Registry (GCR) automatically.
📋 What You'll Learn
Create a cloudbuild.yaml file with build steps
Define a build step to build a Docker image named gcr.io/my-project/my-app
Add a build step to run tests using a simple shell command
Add a build step to push the Docker image to Google Container Registry
Print the final build steps summary
💡 Why This Matters
🌍 Real World
Automating builds and tests helps teams deliver software faster and with fewer errors by catching problems early.
💼 Career
Knowing how to configure Cloud Build is essential for DevOps roles working with Google Cloud to implement CI/CD pipelines.
Progress0 / 4 steps
1
Create the initial Cloud Build configuration file
Create a file called cloudbuild.yaml and add a steps list with one step that uses the docker builder to build an image named gcr.io/my-project/my-app from the current directory (use dir: ".").
GCP
Need a hint?

Use the docker builder image and the build command with the -t flag to tag the image.

2
Add a test step to the build configuration
Add a second step to the steps list that uses the gcr.io/cloud-builders/gcloud builder to run tests with the command sh -c "echo Running tests...".
GCP
Need a hint?

Add a new step with the gcloud builder and use sh -c to run the echo command.

3
Add a push step to upload the Docker image
Add a third step to the steps list that uses the docker builder to push the image gcr.io/my-project/my-app to Google Container Registry.
GCP
Need a hint?

Use the docker builder again with the push command and the image name.

4
Print the summary of build steps
Add a final step that prints Build steps completed successfully! using the gcr.io/cloud-builders/gcloud builder and the command sh -c "echo Build steps completed successfully!".
GCP
Need a hint?

Use the gcloud builder with sh -c to print the success message.