Prepare and test your skills
Prepare and test your skills
Free sample question, answered and explained below. The Professional Cloud DevOps Engineer practice bank has 1,455 more like it. Try 10 free: instant score, no account.
Your team is building a continuous integration pipeline in Cloud Build to package and publish Python libraries to Google Cloud Artifact Registry across different deployment environments (such as staging and production).
You need to create a reusable cloudbuild.yaml configuration that dynamically targets different repository locations and names without hardcoding values, while relying on Cloud Build's default variables for the project ID.
Which configuration and submission command should you use?
This option suggests configuring step-level env blocks in cloudbuild.yaml and passing build-time overrides using the --build-arg CLI flag.
--build-arg flag is specifically used when invoking docker build commands to pass arguments into Dockerfiles. It is not a supported flag for parameterizing generic Cloud Build configuration files via gcloud builds submit.env variables cannot dynamically rewrite top-level Cloud Build step definitions or argument lists before the containerized steps execute.cloudbuild.yaml steps require substitutions (via ${_VAR_NAME}) to dynamically modify command-line arguments and repository URLs prior to container instantiation.--substitutions flag in the Google Cloud CLI is the standard mechanism for supplying variable overrides at build execution time.The pipeline was executing a direct Dockerfile image build and passing arguments to Docker's ARG instructions rather than parameterizing a native multi-step cloudbuild.yaml pipeline.
This option attempts to create custom build variables using standard uppercase variable names without prefixing them with an underscore.
Cloud Build enforces a strict syntax rule: all user-defined substitutions must begin with an underscore (_) followed by uppercase letters, numbers, or underscores (for example, ${_LOCATION}). If custom variables are defined without a leading underscore, Cloud Build treats them as invalid or unpopulated built-in substitutions, causing the build validation or execution step to fail.
$PROJECT_ID, $BUILD_ID, $COMMIT_SHA, and $SHORT_SHA.--substitutions=LOCATION=... via the gcloud CLI will be rejected because LOCATION is not recognized as a valid user substitution.Cloud Build permitted arbitrary naming conventions for custom variables without reserving non-underscored keys for default system substitutions.
This solution uses Cloud Build user-defined substitutions (which require a leading underscore, such as ${_LOCATION} and ${_REPOSITORY}) alongside built-in default substitutions (such as $PROJECT_ID) to parameterize the target Artifact Registry repository URL dynamically.
${_LOCATION} and ${_REPOSITORY}, the same cloudbuild.yaml file can publish packages to different Artifact Registry repositories or regions without modifying the pipeline definition file.$PROJECT_ID with the active Google Cloud project ID running the build or executing the trigger.gcloud builds submit command specifies the parameter values using the --substitutions flag with matching leading underscores (_LOCATION="...",_REPOSITORY="...").twine directly with Artifact Registry's HTTPS repository endpoints (https://${_LOCATION}-python.pkg.dev/$PROJECT_ID/${_REPOSITORY}/).Cloud Build strictly distinguishes between default environment variables provided by the service runtime and custom variables passed by the user. Using leading underscores for custom variables ensures correct parsing during build execution.
This option creates custom variables for all parameters, including defining a user substitution ${_PROJECT_ID} to manually pass the project ID during build invocation.
$PROJECT_ID at runtime based on the active project context or build trigger. Creating and passing an explicit ${_PROJECT_ID} parameter adds unnecessary redundancy.$PROJECT_ID are managed automatically by Cloud Build and do not require user-defined parameters in the CLI submission command.The build needed to publish artifacts into a completely different external Google Cloud project than the one executing the Cloud Build worker.
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