
Answer-first summary for fast verification
Answer: Execute `gcloud builds submit --config=[CONFIG_FILE_PATH] --gcs-log-dir=[GCS_LOG_DIR] [SOURCE]`
The correct command is `gcloud builds submit --config=[CONFIG_FILE_PATH] --gcs-log-dir=[GCS_LOG_DIR] [SOURCE]`. This command not only builds the container image and pushes it to Google Container Registry (GCR) but also uploads the build logs to Google Cloud Storage, fulfilling all specified requirements. The `--config` flag specifies the build configuration file, and `--gcs-log-dir` indicates the directory in Google Cloud Storage for the logs. The `submit` operation is the correct choice for building images and pushing them to GCR, unlike `run` or `push`, which are not supported operations for this purpose. For more details, refer to the [Google Cloud SDK documentation](https://cloud.google.com/sdk/gcloud/reference/builds/submit) and [Cloud Build documentation](https://cloud.google.com/cloud-build/docs/building/build-containers).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Your company has recently migrated all its infrastructure to Google Cloud Platform (GCP) and intends to use Google Cloud Build for building all container images. The requirements include storing build logs in Google Cloud Storage and pushing the images to Google Container Registry. Given the following cloud build YAML configuration file:
steps:
- name: ‘gcr.io/cloud-builders/docker’
args: [‘build’, ‘-t’, ‘gcr.io/[PROJECT_ID]/[IMAGE_NAME]’, ‘.’]
images: [‘gcr.io/[PROJECT_ID]/[IMAGE_NAME]’]
steps:
- name: ‘gcr.io/cloud-builders/docker’
args: [‘build’, ‘-t’, ‘gcr.io/[PROJECT_ID]/[IMAGE_NAME]’, ‘.’]
images: [‘gcr.io/[PROJECT_ID]/[IMAGE_NAME]’]
How should you execute Cloud Build to meet these requirements?
A
Execute gcloud builds run --config=[CONFIG_FILE_PATH] --gcs-log-dir=[GCS_LOG_DIR] [SOURCE]
B
Execute gcloud builds submit --config=[CONFIG_FILE_PATH] --gcs-log-dir=[GCS_LOG_DIR] [SOURCE]
C
Execute gcloud builds submit --config=[CONFIG_FILE_PATH] [SOURCE]
D
Execute gcloud builds push --config=[CONFIG_FILE_PATH] [SOURCE]
No comments yet.