CI/CD Pipelines Questions with Answers

21 practice questions on CI/CD Pipelines (DevOps & Kubernetes) with answers and step-by-step solutions. Try 10 samples below, then practise all 21 free in the AptiNest app.

Sample questions

Question 1Easy

What does 'pipeline as code' mean?

  1. Pipelines are configured only through a web UI
  2. Pipelines compile into binaries
  3. Each developer writes and runs their own pipeline locally, then uploads the results to the server
  4. Pipeline steps live in a versioned file in the repo

Answer: D. Pipeline steps live in a versioned file in the repo

Explanation

Files like a Jenkinsfile or workflow YAML are reviewed and versioned with the code.

Step-by-step solution

  1. Pipeline as code means pipelines are defined in files.
  2. These files are stored in a repository with the source code.
  3. The files are versioned, allowing tracking of changes.
  4. This makes collaboration and automation easier.
  5. Pipeline steps live in a versioned file in the repo.

Why the other options are wrong

  • A. UI-only config is the opposite of pipeline as code; the definition lives outside version control.
  • B. Pipelines run on a CI server, not compiled into binaries; a pipeline is a set of defined steps.
  • C. Pipeline as code runs on the shared server from its repo file, not on each developer's laptop.

Tip: Use version control for pipelines to ensure transparency and repeatability.

Question 2Easy

Which is a typical CI pipeline stage order?

  1. Package → deploy → build → test
  2. Test → deploy → build → package
  3. Build → test → package → deploy
  4. Deploy → test → build → package

Answer: C. Build → test → package → deploy

Explanation

You compile, verify, produce an artifact, then deploy it.

Step-by-step solution

  1. A CI pipeline compiles the code first.
  2. Then it runs tests to check the build.
  3. It then packages an artifact and deploys it. Option C (build, test, package, deploy) is correct.

Why the other options are wrong

  • A. Packaging comes after build and test, not before them.
  • B. Deploying before building means there is nothing built to deploy.
  • D. Deploying first puts untested code into production.

Tip: Build, then test, then package, then deploy is the usual CI order.

Question 3Easy

What typically triggers a CI pipeline?

  1. A user logging in to the app
  2. The CI server rebooting on a weekly schedule only
  3. A push or pull request to the repository
  4. A database backup finishing

Answer: C. A push or pull request to the repository

Explanation

Webhooks on commits and PRs start builds so every change is checked.

Step-by-step solution

  1. A CI pipeline runs automatically when repository events happen.
  2. A push to the repository or a pull request is the usual trigger, so each change gets checked.
  3. The correct answer is option C, a push or pull request to the repository.

Why the other options are wrong

  • A. A user logging in to the app does not start a CI pipeline.
  • B. A weekly schedule is only one option, not the usual trigger.
  • D. A database backup finishing is not a normal CI trigger.

Tip: Commits and pull requests are the usual CI triggers.

Question 4Easy

Which is NOT usually a goal of CI/CD?

  1. Fast feedback on changes
  2. Repeatable, automated deployments
  3. Smaller, lower-risk releases
  4. Large, infrequent releases

Answer: D. Large, infrequent releases

Explanation

CI/CD aims for small, frequent, automated releases; big-bang releases are what it replaces.

Step-by-step solution

  1. CI/CD focuses on small changes to reduce risk.
  2. Automated processes ensure consistent deployments.
  3. Fast feedback helps catch issues early.
  4. Large releases are avoided for better control.
  5. So, large, infrequent releases are not a goal.

Why the other options are wrong

  • A. Fast feedback is a core CI/CD goal, since failing builds are caught early.
  • B. Repeatable, automated deployments are a core CI/CD goal, which removes manual steps.
  • C. Smaller, lower-risk releases are a core CI/CD goal, since small changes are easier to roll back.

Tip: Remember: CI/CD replaces big-bang releases with frequent, automated ones.

Question 5Medium

Why put fast checks such as lint and unit tests early in a pipeline?

  1. To fail fast and give quick feedback
  2. Slow tests cannot run in CI
  3. They are more important than integration tests
  4. Linting must finish before code compiles in every language

Answer: A. To fail fast and give quick feedback

Explanation

Cheap checks catch most problems in minutes, saving time before expensive stages.

Step-by-step solution

  1. Fast checks like lint and unit tests find errors early.
  2. Early detection saves time on later, more complex steps.
  3. Quick feedback helps fix issues faster.
  4. This reduces overall development time and cost.
  5. Final answer: To fail fast and give quick feedback.

Why the other options are wrong

  • B. Slow tests can run in CI; the point of ordering is to fail early, not to exclude slow tests.
  • C. Unit tests are not more important than integration tests; both matter, and they run at different stages.
  • D. Linting does not have to finish before compiling in every language; that is not a general rule.

Tip: Fail fast, save time.

Question 6Medium

Branch protection rules on main usually require:

  1. That only the repository owner can create pull requests
  2. Passing CI checks and reviews before merge
  3. Deleting the branch after each commit
  4. Force pushes to be allowed

Answer: B. Passing CI checks and reviews before merge

Explanation

Required checks stop broken or unreviewed code reaching the main branch.

Step-by-step solution

  1. Branch protection is a set of rules on the main branch.
  2. It typically requires CI checks to pass and a reviewer to approve before merge.
  3. Option B matches this: passing checks and reviews before merge.

Why the other options are wrong

  • A. Protection rules govern merges to the branch, not who may open pull requests.
  • C. Deleting branches after each commit is unrelated to protection.
  • D. Protected branches normally block force pushes.

Tip: Protected main means required checks and reviews before any merge.

Question 7Medium

Why should CI runners use ephemeral, clean environments?

  1. It keeps old dependency caches and build outputs forever, so later builds can reuse them
  2. Clean runners never fail
  3. Ephemeral runners need no internet access
  4. Leftover state from earlier builds cannot affect results

Answer: D. Leftover state from earlier builds cannot affect results

Explanation

Fresh environments make builds reproducible and reduce the risk of one job tampering with another.

Step-by-step solution

  1. Ephemeral runners discard previous states after each build.
  2. Leftover files from earlier jobs can't influence new builds.
  3. This ensures consistent and reliable results every time.

Why the other options are wrong

  • A. Keeping caches forever is not the point; ephemeral runners discard state, and caches are a separate, controlled feature.
  • B. Clean runners can still fail for many reasons, such as bad code or flaky tests.
  • C. Ephemeral runners still need internet access to pull code and dependencies; that is unrelated to cleanliness.

Tip: Use fresh environments to avoid build conflicts and ensure accuracy.

Question 8Medium

Feature flags help continuous delivery because:

  1. Unfinished features can ship turned off
  2. They speed up compilation by excluding the flagged code paths from the build entirely
  3. They make every deploy a rollback
  4. They remove the need for tests

Answer: A. Unfinished features can ship turned off

Explanation

Deploying code is separated from releasing features, so main stays deployable.

Step-by-step solution

  1. A feature flag wraps new code in a switch.
  2. The code can be deployed to production while the flag is off.
  3. So unfinished work ships without being visible to users. Option A is correct.

Why the other options are wrong

  • B. Flags do not remove code from the build; the code still ships, just switched off.
  • C. Flags reduce the need for rollbacks; they do not make every deploy a rollback.
  • D. Flags do not replace tests.

Tip: Flags separate deploying code from releasing features, so main stays deployable.

Question 9Hard

A test fails randomly about 1 in 20 runs with no code change. What is the healthy response?

  1. Rerun the pipeline until it passes, since a pass shows the code is fine and the failure was noise
  2. Treat it as a flaky test: quarantine it and fix the root cause
  3. Delete all integration tests
  4. Lower the test coverage target

Answer: B. Treat it as a flaky test: quarantine it and fix the root cause

Explanation

Flaky tests erode trust in CI; tracking and fixing them keeps red builds meaningful.

Step-by-step solution

  1. A test that fails about 1 in 20 runs with no code change is flaky.
  2. Rerunning until it passes hides the problem and makes red builds meaningless.
  3. Quarantine the test so it stops blocking, then fix its root cause. Option B is the healthy response.

Why the other options are wrong

  • A. Rerunning until green hides the flaw and treats a real signal as noise.
  • C. Deleting integration tests removes coverage instead of fixing the flaky test.
  • D. Lowering the coverage target does not address the flaky test.

Tip: A flaky test is a bug in the test: quarantine it, then fix the cause rather than rerunning or deleting.

Question 10Hard

Database schema changes in CD are safest when they are:

  1. Combined with large data rewrites in one step
  2. Backward compatible, so old and new app versions both work
  3. Done manually in production by a DBA after each deploy, so they can be checked line by line
  4. Applied after every Pod has been deleted

Answer: B. Backward compatible, so old and new app versions both work

Explanation

During a rollout both versions run; expand-then-contract changes avoid breaking the old version.

Step-by-step solution

  1. Backward compatibility ensures old and new apps work together.
  2. This prevents service disruption during schema changes.
  3. It allows for smooth transitions without data loss.
  4. Changes are tested with existing systems.
  5. Final answer: Backward compatible, so old and new app versions both work.

Why the other options are wrong

  • A. Combining schema changes with big data rewrites in one step raises risk; keep them separate.
  • C. Manual DBA changes after each deploy are not repeatable and bypass the automated pipeline.
  • D. Deleting all Pods first causes downtime; schema changes must work with running old and new Pods.

Tip: Always prioritize backward compatibility for safe schema updates.

Practise all 21 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all DevOps & Kubernetes topics · All topics