Bird
0
0

In a CI pipeline, you want to push a Docker image only if the build and tests succeed. Which is the best way to ensure this?

hard📝 Workflow Q15 of 15
Docker - in CI/CD
In a CI pipeline, you want to push a Docker image only if the build and tests succeed. Which is the best way to ensure this?
AAdd a separate job that depends on build and test jobs and pushes the image
BPush the image immediately after the build step without waiting for tests
CPush the image before running tests to save time
DPush the image manually after the pipeline finishes
Step-by-Step Solution
Solution:
  1. Step 1: Understand CI job dependencies

    To push only after build and tests succeed, create a job that runs after those jobs complete successfully.
  2. Step 2: Why other options fail

    Pushing before tests risks pushing broken images; manual push loses automation benefits.
  3. Final Answer:

    Add a separate job that depends on build and test jobs and pushes the image -> Option A
  4. Quick Check:

    Push after success = dependent job [OK]
Quick Trick: Use dependent jobs to control push timing [OK]
Common Mistakes:
  • Pushing before tests complete
  • Manual push breaks automation
  • Ignoring job dependencies in CI

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes