Exams / DVA-C02 / CI/CD with CodePipeline and CodeBuild / Question 1
DVA-C02 practice question: CI/CD with CodePipeline and CodeBuild (1 of 3)
Deployment A free question from our original DVA-C02 practice exam. Try it, then open the answer to see why each option is right or wrong.
An AWS CodeBuild project runs as the build stage of an AWS CodePipeline pipeline. The build succeeds and writes the compiled site to a dist folder, but the next stage receives no files to deploy. The buildspec is:
version: 0.2
phases:
install:
commands:
- npm ci
build:
commands:
- npm run build
What should the developer change?
Choose one answer.
- AA. Move npm run build from the build phase into the post_build phase.
- BB. Add a cache section to the buildspec that lists the dist folder.
- CC. Add an artifacts section with files '**/*' and base-directory dist.
- DD. Add an env section to the buildspec that sets OUTPUT_DIR to dist.
Show the answer and explanation
Answer: C
- A. Wrong: The phase in which the build runs does not decide what CodeBuild uploads as output.
- B. Wrong: Caching speeds up later builds by reusing files such as dependencies. Cached files are not passed to the next pipeline stage.
- C. Right: Correct. The artifacts section tells CodeBuild which files form the output artifact that CodePipeline passes on.
- D. Wrong: An environment variable is only visible to build commands. It does not tell CodeBuild what to upload.
Explanation
In a buildspec, the artifacts section defines the build output. files selects paths, and base-directory sets the top-level folder whose contents are packaged without the folder name. Without it, CodeBuild produces no output artifact for later pipeline stages.
Study
Keep practising
Answer questions with a score at the end, or practise just this topic with the explanation after each one. No sign-up needed.