GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice question 33 of 35

You are using Cloud Build to build and test application source code stored in Cloud Source Repositories. The build process requires a build tool not available in the Cloud Build environment. What should you do?

Full set: 265 questions
Answer options
A: Download the binary from the internet during the build process.
B: Build a custom cloud builder image and reference the image in your build steps. Correct answer
C: Include the binary in your Cloud Source Repositories repository and reference it in your build scripts.
D: Ask to have the binary added to the Cloud Build environment by filing a feature request against the Cloud Build public Issue Tracker.
Correct Answer:
B. Build a custom cloud builder image and reference the image in your build steps.
Explanation

The standard and recommended practice for using tools not available in the default Cloud Build environment is to create a custom builder. This involves creating a container image that includes the necessary tool, pushing that image to a registry like Artifact Registry, and then referencing it as a step in your cloudbuild.yaml configuration file. This approach ensures that builds are self-contained, repeatable, and secure, as you are not relying on external resources during the build process and have full control over the build environment's dependencies.

Why Incorrect

A. Downloading a binary from the internet during the build is unreliable and insecure. The external source could become unavailable, or the binary could be compromised, leading to build failures or security vulnerabilities.
C. Including binaries in a source code repository is a poor practice. It significantly increases the repository size, slowing down operations like cloning, and mixes build artifacts with source code.
D. Filing a feature request is not a direct or timely solution to the immediate problem. There is no guarantee the request will be accepted or implemented, and it does not help with current build requirements. ---

References

1. Google Cloud Documentation - Creating custom build steps: "If the tool you want to use in your build is not available as a supported build step, you can create your own custom build step. A custom build step is a container image that the Cloud Build worker VM pulls and runs with your source mounted under /workspace." This page explicitly describes the process for option B as the solution.

2. Google Cloud Documentation - Cloud Builders: "Cloud Build provides a set of pre-built container images that you can use as build steps... If none of these builders meet your needs, Cloud Build allows you to create your own custom builders." This confirms that creating custom builders is the intended extension mechanism.

3. Google Cloud Documentation - Build configuration overview: In the section "Build steps", the name field is described as: "The cloud builder to use for this build step. You can use a supported builder, a builder from Docker Hub, or a builder from a container registry that your build service account has access to..." This highlights the flexibility of using custom images stored in a registry.

Scroll to Top