Courseiva
SDLC Automation →hardMultiple Choice

DOP-C02 SDLC Automation Practice Question

Exhibit

Build complete
[Container] 2024/03/15 14:30:00 Phase complete: BUILD State: FAILED
[Container] 2024/03/15 14:30:00 Phase context: statusCode: COMMAND_EXECUTION_ERROR, Message: Error while executing command: ./gradlew build. Reason: exit status 1

Refer to the exhibit. A developer is troubleshooting a failed AWS CodeBuild build. The buildspec file contains the following build commands: 'pre_build' - run linting, 'build' - './gradlew build', 'post_build' - package artifact. The error occurs in the build phase. Which of the following is the MOST likely cause?

⚠ Common exam trap

Many candidates confuse the phase in which each command runs (pre_build, build, post_build) and attribute the error to a step that executes in a different phase, rather than recognizing that the error occurs specifically in the build phase where './gradlew build' runs.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The Gradle build encountered compilation or test errors.

The error occurs in the build phase, which executes './gradlew build'. Gradle's build task compiles source code and runs tests by default. If compilation fails or tests fail, Gradle exits with a non-zero exit code, causing AWS CodeBuild to mark the build phase as failed. The error message in the build logs would typically show compilation errors or test failures.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    The Gradle build encountered compilation or test errors.

    Why this is correct

    The failing command `./gradlew build` invokes Gradle's primary lifecycle task, which compiles all production and test sources and then executes the test suite. Any compilation error or failed test causes Gradle to abort with a non-zero exit code (typically 1), producing a 'BUILD FAILED' status. Since this failure occurs in the `build` phase and the exit code originates from the Gradle process itself, this is the direct and correct explanation.

  • ✗

    The build environment ran out of disk space.

    Why it's wrong here

    An out-of-disk-space condition would not appear as a Gradle exit status 1 from `./gradlew build`; it would instead generate filesystem-level errors such as 'No space left on device' or 'Failed to write...' when Gradle tries to download dependencies or write its cache. Such an environment failure would likely interrupt the process earlier, for example during the `install` or `pre_build` phase, not as a clean non-zero exit from the build command itself.

  • ✗

    The artifact packaging step failed.

    Why it's wrong here

    The artifact packaging step, such as creating a ZIP/tarball or copying outputs to a designated directory, is defined in the `post_build` phase, which executes only after the `build` phase has exited successfully. Because `./gradlew build` stopped with status 1, the pipeline aborted during the `build` phase, meaning `post_build` never ran and therefore cannot be the cause of this failure.

  • ✗

    The linting step failed.

    Why it's wrong here

    In this buildspec, the `build` phase runs `./gradlew build`, a Gradle task that compiles code and runs tests; a separate linting task would be invoked explicitly (e.g., `./gradlew lint`) in `pre_build` or as its own command. A lint failure would produce lint-specific output and its own non-zero exit from that distinct command, not the generic status 1 from `./gradlew build`. Thus the linting step is not what caused the failure shown.

About these practice questions

Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.