Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
Your team is setting up an automated multi-step integration testing pipeline in Cloud Build for a microservice. The pipeline must meet the following requirements:
How should you structure and configure the Cloud Build pipeline?
RUN commands inside the microservice's Dockerfile, writing the JUnit XML report to the container's /app directory. Submit the build using gcloud builds submit --tag without a cloudbuild.yaml file.This approach places dependency installation and integration test execution directly inside the application's Dockerfile and triggers a single-step Docker build with gcloud builds submit --tag instead of using a cloudbuild.yaml pipeline.
--tag bypasses cloudbuild.yaml, making it impossible to configure artifacts.objects to extract and upload the JUnit XML test report from /app to Cloud Storage.Dockerfile build cannot receive configuration files dynamically generated by an earlier Cloud Build step or coordinate multiple builder containers.Dockerfile leaves unnecessary test dependencies, binaries, and intermediate files inside the final container layers.RUN instruction in a Dockerfile creates an immutable image layer; files created and not deleted within the same command permanently increase image size and registry transfer time.gcloud builds submit --tag is designed solely for simple container builds, not multi-step integration test orchestration.Using gcloud builds submit --tag with a single Dockerfile would be appropriate if you only needed to package a simple application image with no multi-step test orchestration, no cross-step configuration sharing, and no test report archiving.
Using cloudbuild.yaml separates building and testing steps into dedicated builder containers, keeping the final microservice runtime image minimal and secure while preserving test artifacts.
gcr.io/cloud-builders/<tool-name> directly in the name field of a step in cloudbuild.yaml without prebuilding it. Store the generated test configuration in /workspace, and list the JUnit XML report path in the top-level images field to archive it.This configuration attempts to reference an unbuilt community builder under the official gcr.io/cloud-builders/ namespace and uses the images field in cloudbuild.yaml to store non-container test artifacts.
gcr.io/cloud-builders/. Community-contributed builders do not have prebuilt images available; their source code must be built and pushed to your own Artifact Registry repository first, and proprietary third-party CLI tools require a custom builder.images field: The images field strictly expects Linux Docker container images to be pushed to Artifact Registry. Specifying a JUnit XML file path in images does not upload files to Cloud Storage and causes the build to fail because no matching container image is produced.gcr.io/cloud-builders/ cover common tools like docker, gcloud, git, and mvn.docker-compose or helm) must be cloned, built, and pushed to a project-owned registry before a cloudbuild.yaml step can reference them.artifacts.objects field pointing to a Cloud Storage bucket.This pattern would only work if the tool were a Google-maintained prebuilt Cloud Builder and the output artifact being archived were a built Docker container image destined for Artifact Registry rather than a JUnit XML report.
Although storing intermediate configuration files in /workspace is valid in Cloud Build, the pipeline will fail immediately when trying to pull a nonexistent builder image and again during artifact publishing.
cloudbuild.yaml file with sequential steps using gcr.io/cloud-builders/docker to build the service image and your custom builder image in the name field to run the tests. Share the generated test configuration via the /workspace directory, and configure the artifacts.objects field to upload the JUnit XML report to Cloud Storage.A custom builder in Cloud Build is a user-created container image packaged with specialized tools, binaries, or scripts that are not available in public registries or prebuilt Cloud Builders. By defining a multi-step cloudbuild.yaml configuration file, Cloud Build orchestrates each task inside its own container on a fresh, ephemeral virtual machine.
docker run), preventing leftover files or state from affecting test outcomes.name field./workspace for every step. Any configuration file written to /workspace by an earlier step is immediately accessible to the integration test step.artifacts.objects section specifies a Cloud Storage location and file paths, automatically uploading the generated JUnit XML report after all build steps succeed.cloudbuild Docker network, enabling inter-step service communication if needed.Combining a custom builder in Artifact Registry with /workspace file sharing and artifacts.objects leverages Cloud Build's native orchestration primitives, delivering fast, repeatable integration testing without managing persistent build servers.
cloudbuild.yaml with waitFor: ['-'] on all steps so the container build and integration test steps run concurrently. In the test step, use the public ubuntu image to download and install the CLI tool at runtime, read the configuration file from /tmp created by the previous step, and upload the JUnit XML report via gcloud.This configuration forces all cloudbuild.yaml steps to execute in parallel using waitFor: ['-'], dynamically installs the testing CLI inside a generic ubuntu container at runtime, and attempts to share data between steps through /tmp.
waitFor: ['-'] instructs Cloud Build to start those steps immediately at the beginning of the build in parallel. The integration test step will execute before the earlier step finishes building the image or writing the test configuration file./tmp: Cloud Build runs every step in a separate Docker container. Only the /workspace directory is mounted and persisted across containers; files written to /tmp exist only inside that single container and disappear when the step exits.ubuntu image introduces network fragility and version drift rather than guaranteeing a reproducible environment.waitFor causes Cloud Build to execute steps one after another in order, which is required when downstream steps depend on upstream outputs./workspace (such as /tmp or /root) are isolated per step.waitFor: ['-'] would be appropriate for independent tasks that have no shared file dependencies (such as running separate linters in parallel), provided any shared inputs were already present in /workspace.
Even if a subsequent step used gcloud to copy files, the test step would fail to locate the configuration file in /tmp and would race against upstream steps due to waitFor: ['-'].
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated