
Answer-first summary for fast verification
Answer: Build a new Docker container that examines the files in /workspace and then checks and adds a copyright for each source file. Changed files are explicitly committed back to the source repository.
The correct approach involves using a Docker container in Cloud Build to check and add the copyright comment to files in the /workspace directory. Since Cloud Build checks out the source code into /workspace, any changes made here are available to subsequent build steps. However, to ensure compliance with the corporate policy, the corrected files must be committed back to the source repository. This prevents future builds from reprocessing the same issue and enforces the policy in the repository itself. Options C and D incorrectly reference Cloud Storage instead of /workspace, which is where Cloud Build stages source code. Option B does not commit changes back, leaving the repository non-compliant. Option A addresses both validation and enforcement by modifying files in /workspace and committing them to the repository.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
How can you implement a custom Cloud Build step that triggers on each source commit to validate the presence of a copyright comment at the beginning of source files and automatically add one if missing, in compliance with your company's policy?
A
Build a new Docker container that examines the files in /workspace and then checks and adds a copyright for each source file. Changed files are explicitly committed back to the source repository.
B
Build a new Docker container that examines the files in /workspace and then checks and adds a copyright for each source file. Changed files do not need to be committed back to the source repository.
C
Build a new Docker container that examines the files in a Cloud Storage bucket and then checks and adds a copyright for each source file. Changed files are written back to the Cloud Storage bucket.
D
Build a new Docker container that examines the files in a Cloud Storage bucket and then checks and adds a copyright for each source file. Changed files are explicitly committed back to the source repository.
No comments yet.