DevOps CI/CD interview questions
Reviewed by Mark Dickie · Last updated
DevOps CI/CD is the practice of automating the build, test, and deployment stages of software delivery so that changes move from a developer's commit to production with minimal manual intervention. For interviews, you should understand pipeline stages (build, test, stage, deploy), common deployment strategies (blue-green, canary, rolling), and the trade-offs between speed and safety in release automation. Expect questions on tooling choices (Jenkins, GitHub Actions, GitLab CI), pipeline-as-code concepts, artifact management, and how to handle failures and rollbacks.
| Topic | What to Study |
|---|---|
| Pipeline stages | Source, build, test, stage, deploy — and what happens at each |
| Deployment strategies | Blue-green, canary, rolling, and when to pick each |
| Pipeline-as-code | YAML/declarative pipeline definitions, templating, reuse |
| Artifacts & images | Docker image tagging, registry storage, immutable artifacts |
| Rollback & failure | Automated rollback triggers, health checks, circuit breakers |
| Security in CI/CD | Secrets management, scanning in pipeline, least-privilege runners |
What does a DevOps CI/CD interview test?
Interviewers want to see that you can design a pipeline end to end and reason about failure modes, not just list tools. You will likely be asked to diagram a pipeline for a sample application, explain where tests fit, and describe what happens when a stage fails. They also probe your understanding of environment promotion — how a build artifact moves from dev through staging to production — and what controls prevent a bad release from reaching users.
How should I prepare for CI/CD pipeline questions?
- Draw a full pipeline for a web application from commit to production, labeling every stage and the tool responsible for it.
- Compare at least two CI/CD tools (e.g., GitHub Actions vs. Jenkins) and be ready to explain why you would choose one over the other for a given team size or project.
- Practice explaining a canary deployment and a blue-green deployment step by step, including how traffic is shifted and how rollback works in each case.
- Study how secrets and credentials are injected into pipelines without being exposed in logs or source control.
- Review common pipeline anti-patterns — long-running pipelines, flaky tests, manual approval bottlenecks — and how to address them.
What are the most common CI/CD interview mistakes?
Candidates often confuse continuous delivery with continuous deployment. Continuous delivery means every change is ready to deploy but release is a manual gate; continuous deployment pushes every passing build straight to production with no human approval. Getting this distinction wrong signals a surface-level understanding. Another frequent error is describing a pipeline without mentioning testing — if you cannot say where unit, integration, and security tests run and what happens when they fail, the interviewer will assume you have not operated a real pipeline.
Key facts
- Tarmac has 26 DevOps interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
- Tarmac last reviewed these DevOps interview questions on 31 August 2026.
At a glance
| Questions | 25 shown · 26 in the bank |
|---|---|
| Difficulty | 1–5 of 5 |
| Formats | Multiple answer, Multiple choice, Fill in the blank, True / false, Ordering, Short answer, Code output, Design exercise, Flashcard |
What you'll review
- build artifacts
- pipeline as code
- pipeline stages
- deployment gates
- continuous delivery vs deployment
Practice questions
DevOps/ci-cd-practice/build-artifacts
In a CI/CD pipeline, which of the following are generally accepted characteristics of a well-designed build artifact?#
Options
Pick every one that applies.
Show answer
A well-designed build artifact is immutable once published, produced from a specific reproducible source commit, and promoted unchanged across environments. It should NOT bundle environment-specific secrets or config; those are injected at runtime so the same artifact can be safely deployed everywhere.
A well-designed build artifact is immutable (it never changes once published), built from a reproducible source state, and promoted as-is across environments so that what was tested is what is deployed. Baking environment-specific secrets into the artifact is an anti-pattern — secrets and environment config should be injected at runtime, not embedded in the artifact.
DevOps/ci-cd-practice/build-artifacts
Which of the following are commonly used as build artifacts in CI/CD pipelines?#
Options
Pick every one that applies.
Show answer
Common build-artifact formats in CI/CD pipelines include Docker container images, compiled JAR or WAR files, and ZIP archives of binaries and assets. Git commit messages are source-control metadata, not build artifacts.
Docker images, compiled JAR/WAR files, and ZIP archives of binaries and assets are all standard build-artifact formats that CI pipelines produce, version, and store in an artifact registry for downstream deployment. Git commit messages are metadata about source changes, not build artifacts.
DevOps/ci-cd-practice/pipeline-as-code
Which of the following is a defining characteristic of pipeline-as-code?#
Options
Show answer
Pipeline-as-code means defining CI/CD pipeline configuration in version-controlled text files such as YAML or Groovy, rather than configuring it manually through a web UI. This lets teams review, branch, and reproduce their build and deployment workflows exactly like application code.
Pipeline-as-code means the CI/CD pipeline definition lives in version-controlled text files—commonly YAML (e.g., GitHub Actions, GitLab CI) or code in a DSL like Groovy (Jenkinsfile). The other options each describe the opposite: UI-only configuration, compiled binaries, or manual stage management all defeat the purpose of treating the pipeline itself as reviewable, reproducible code.
DevOps/ci-cd-practice/pipeline-stages
In a standard CI/CD pipeline, the stage that compiles source code, resolves dependencies, and produces a deployable artifact (such as a JAR, Docker image, or binary) is called the _____ stage.#
Show answer
In a standard CI/CD pipeline, the stage that compiles source code, resolves dependencies, and produces a deployable artifact (such as a JAR, Docker image, or binary) is called the Build stage.
The build stage is the pipeline phase responsible for compiling source code, resolving dependencies, and packaging the output into a deployable artifact. It sits after the source/commit stage and before the test stage in a typical CI/CD pipeline. The other common stages—test, deploy, and monitor—each serve different purposes: test validates the artifact, deploy pushes it to an environment, and monitor observes it in production.
DevOps/ci-cd-practice/build-artifacts
In a CI/CD pipeline, build artifacts (such as compiled binaries, JAR files, or Docker images) should be committed to the Git repository alongside source code so that they are version-controlled and available to every pipeline stage.#
Options
Show answer
False. Build artifacts like compiled binaries, JAR files, and Docker images should be stored in a dedicated artifact repository (e.g., Artifactory, Nexus, or a container registry), not committed to Git. Committing artifacts bloats the repository with large binary files, creates unnecessary merge conflicts, and duplicates data that can always be reproduced by rebuilding from source.
Build artifacts are derived from source code and should be stored in an artifact repository (e.g., Nexus, Artifactory, a container registry), not committed to Git. Committing artifacts bloats the repository, creates merge conflicts, and duplicates information already recoverable by rebuilding from source. Git is designed for source code and text, not large binary files.
DevOps/ci-cd-practice/build-artifacts
In a mature CI/CD practice, the same immutable build artifact that passed tests in the staging environment should be promoted to production — rather than rebuilding a new artifact from source for the production deployment.#
Options
Show answer
True. The same immutable build artifact that passed tests in staging should be promoted directly to production. Rebuilding from source for production risks producing a subtly different artifact due to changes in build environment, dependency versions, or transient state, which would break the guarantee that the tested software is exactly the shipped software.
Promoting the exact same artifact that was tested ensures that what was verified is what gets deployed. Rebuilding from source introduces risk because differences in build environment, dependency versions, or transient states can produce a subtly different artifact, breaking the guarantee that the tested software is the shipped software.
DevOps/ci-cd-practice/deployment-gates
A _____ gate is a deployment checkpoint that requires explicit human approval before a build can be promoted to the next pipeline stage, adding a manual decision point to an otherwise automated release flow.#
Show answer
A manual approval gate is a deployment checkpoint that requires explicit human approval before a build can be promoted to the next pipeline stage, adding a manual decision point to an otherwise automated release flow.
A manual approval gate (also called an approval gate) pauses the pipeline at a defined stage boundary and waits for a designated person to click approve or reject. Unlike automated quality gates that evaluate metrics programmatically, a manual approval gate inserts a human judgement call into the promotion path.
DevOps/ci-cd-practice/deployment-gates
In CI/CD pipelines, a _____ gate automatically blocks deployment when a measurable signal — such as test pass rate, code coverage, or static-analysis score — falls below the configured _____.#
Show answer
In CI/CD pipelines, a quality gate automatically blocks deployment when a measurable signal — such as test pass rate, code coverage, or static-analysis score — falls below the configured threshold.
A quality gate is an automated checkpoint that evaluates one or more pipeline metrics against predefined thresholds. If a metric like test pass rate or code coverage does not meet the configured minimum threshold value, the gate fails and the pipeline halts, preventing a non-compliant build from being deployed.
DevOps/ci-cd-practice/deployment-gates
In a canary deployment, the progressive rollout is governed by automated health gates that continuously monitor signals such as error rate and latency; if those metrics breach their thresholds, the pipeline triggers an automatic _____ to the previous stable version.#
Show answer
In a canary deployment, the progressive rollout is governed by automated health gates that continuously monitor signals such as error rate and latency; if those metrics breach their thresholds, the pipeline triggers an automatic rollback to the previous stable version.
Canary deployments incrementally route traffic to a new version while health gates watch real-time metrics. When error rates or latency exceed acceptable bounds, the automated safety mechanism performs a rollback — reverting traffic to the last known-good version — to minimize user impact without requiring manual intervention.
DevOps/ci-cd-practice/pipeline-as-code
Which of the following is a primary benefit of defining a CI/CD pipeline as code in a version-controlled file (e.g., Jenkinsfile, .gitlab-ci.yml, or a GitHub Actions workflow YAML) rather than configuring it through a web UI?#
Options
Show answer
Pipeline-as-code lets you version, review, and branch pipeline changes alongside application code. Because the pipeline definition lives in a committed file (e.g., Jenkinsfile or .gitlab-ci.yml), every modification goes through the same code-review and history workflow as source code, giving you traceability, reproducibility, and team collaboration that a web-UI configuration cannot match.
Pipeline-as-code stores the pipeline definition as a text file in the same version-control repository as the application source. This means every change to the pipeline—new stages, modified build steps, environment updates—goes through the same commit, branch, review, and history workflow as application code. Option a is wrong because YAML is parsed and interpreted, not compiled to native code. Option c is wrong because storing the definition as text has no bearing on whether the CI/CD infrastructure or target environments are available. Option d is wrong because the pipeline still orchestrates real build tools, test runners, and deployment tooling—pipeline-as-code does not remove those dependencies.
DevOps/ci-cd-practice/pipeline-stages
A well-structured CI/CD pipeline for a web application typically moves through a defined sequence of stages. Arrange the following stages in the order they should execute, from earliest to latest.#
Put these in order
Show answer
The canonical CI/CD pipeline stage order is Source → Build → Test → Deploy. The pipeline first checks out code from version control, then compiles and packages the artifact, then runs automated tests against that artifact, and finally releases the validated artifact to the target environment. Each stage depends on the output of the prior stage.
A standard CI/CD pipeline begins with Source (pulling code from version control on a commit), then Build (compiling and packaging the artifact), then Test (running automated test suites against the built artifact), and finally Deploy (releasing the validated artifact to an environment). Each stage depends on the output of the one before it, so the order Source → Build → Test → Deploy is the canonical sequence.
DevOps/delivery-flow/continuous-delivery-vs-deployment
What is the precise difference between continuous delivery and continuous deployment?#
Options
Show answer
Continuous delivery and continuous deployment both keep the codebase continuously releasable — every change is automatically built, tested, and proven deployable. The one difference is the production gate. Continuous delivery makes each change release-ready but a human approves the final push to production. Continuous deployment removes that gate: any change that passes the automated pipeline ships to production with no manual step. Continuous integration is the upstream practice both build on — frequent merges with automated testing on each commit.
Both practices keep the codebase in a continuously releasable state — every change is automatically built, tested, and proven deployable. The single distinction is the production gate. Continuous delivery stops just short of production: the artifact is release-ready and could ship at the click of a button, but a human decides when. Continuous deployment removes that button — any change that passes the full automated pipeline is released to production with no manual step. Option d inverts the definitions. Option b confuses these with continuous integration (frequent merges plus automated testing on each commit), which is the upstream practice both build on. Option c is wrong: continuous delivery is about being able to release to prod at any time, not deploying only to staging, and the two terms are genuinely different, not a rename. The interview tell is naming the manual-approval gate as the one differentiator.
DevOps/ci-cd-practice/build-artifacts
In a CI/CD pipeline, what is the practice of compiling/packaging a build artifact exactly once and then promoting that same immutable artifact across environments (e.g., dev → staging → prod) commonly called? Name the practice and briefly state one reason it is preferred over rebuilding from source for each environment.#
Show answer
The practice is called "build once, promote everywhere" (also referred to as promoting immutable artifacts or single-source artifact promotion). One key reason it is preferred is that it guarantees the exact binary tested in staging is the one deployed to production, eliminating drift caused by non-deterministic builds (e.g., differing dependency versions, toolchain updates, or environment-specific build flags) that could introduce defects between environments.
The 'build once, promote everywhere' principle holds that a CI pipeline produces a single, versioned, immutable artifact (e.g., a Docker image, JAR, or tarball) that is then promoted through environments without recompilation. This eliminates non-deterministic build drift — the risk that a rebuild picks up different dependency versions, compiler patches, or environment variables, producing a binary that differs from the one that passed earlier test gates. The keyword 'immutable' captures the core constraint: once built, the artifact is never modified, only re-tagged or copied as it moves downstream.
DevOps/ci-cd-practice/deployment-gates
In a CI/CD pipeline, a _____ gate samples live telemetry — such as error rate and p99 latency — for a fixed observation window after routing a small percentage of production traffic to the new release. The pipeline proceeds to full rollout only if every metric threshold stays within its defined limit throughout that window; otherwise the release is automatically rolled back.#
Show answer
In a CI/CD pipeline, a canary gate samples live telemetry — such as error rate and p99 latency — for a fixed observation window after routing a small percentage of production traffic to the new release. The pipeline proceeds to full rollout only if every metric threshold stays within its defined limit throughout that window; otherwise the release is automatically rolled back.
A canary gate (or canary release gate) is the standard deployment-gate pattern in which a new version receives a small slice of real traffic while automated checks observe health metrics for a set duration. If any threshold is breached during the observation window, the gate fails and the pipeline triggers a rollback; only a clean window allows the rollout to expand to full traffic. The name comes from the 'canary in a coal mine' metaphor, where the small group serves as an early-warning signal for the broader deployment.
DevOps/ci-cd-practice/pipeline-as-code
A team stores their Jenkins pipeline definition in a Jenkinsfile committed to the application repository. The Jenkinsfile loads a shared pipeline library from a separate Git repository via library 'shared-pipeline-lib' (no version or commit pinned). Which statement about this pipeline-as-code setup is correct?#
Options
Show answer
A change to the shared library's default branch can modify every consuming pipeline with no commit in any application repository. Because library 'shared-pipeline-lib' specifies no pinned version, Jenkins resolves the library from its default branch at each build, so the library and the Jenkinsfile are not coupled to the same commit and the library's changes are reviewed in its own repo, not the application's.
Because library 'shared-pipeline-lib' is declared without a version or commit qualifier, Jenkins resolves it from the library's default branch at build time. A merge to that default branch therefore changes the pipeline behavior for every application that loads it — even though none of those application repositories received a commit. Option (b) is wrong because the library lives in its own repository, so its changes are reviewed through that repository's PR process, not the application's. Option (c) is wrong because the library is not pinned to the application repo's commit; only the Jenkinsfile is. Option (d) is wrong because a Jenkinsfile is still required in each application repo to declare the library load and any app-specific configuration.
DevOps/ci-cd-practice/build-artifacts
A pipeline builds an immutable artifact tagged with the commit SHA and promotes the same artifact through environments (it never rebuilds per env). After deploying v=git-9f3a1c to prod, a regression appears. The rollback script runs the commands below. What does the rollback do, and is it safe?#
PREV=$(deploy-history prod --nth 2 --field artifact) # -> app:git-2b7e08
echo "rolling back to $PREV"
deploy prod --artifact "$PREV" # re-deploys the exact bytes that ran beforeOptions
Show answer
It re-deploys the exact previously-running artifact (app:git-2b7e08) with no rebuild, so the rollback is fast and reproducible — you get back the bytes that were known-good in prod
The whole value of building once and promoting an immutable, SHA-tagged artifact shows up at rollback time. The script looks up the artifact that was running two deploys ago (app:git-2b7e08) and re-deploys those exact bytes — no recompilation, no dependency resolution, no fresh image build. That makes the rollback fast and, crucially, reproducible: you are restoring the artifact that was already proven in prod, not a hopefully-equivalent rebuild. Option b describes the rebuild-per-environment anti-pattern, which the prompt explicitly rules out — rebuilding from an old commit can silently pull newer transitive dependencies or a newer base image and yield a different binary, defeating the point of rolling back. Option c is the opposite of true: immutability is what enables clean rollback by tag. Option d is the important caveat stated as a wrong answer — re-deploying an artifact rolls back code only; database migrations are not reversed by this and must be handled separately (which is why backward-compatible, expand-then-contract migrations matter).
DevOps/ci-cd-practice/deployment-gates
You are the platform lead for a large e-commerce platform running 40+ microservices on Kubernetes. Each service team owns its own CI/CD pipeline and can deploy independently. The organization wants to introduce deployment gates so that no service reaches production without passing automated checks, but without re-centralizing release approval or creating a single bottleneck team.#
Show answer
Gate architecture: Each pipeline has five stages with both team-configurable and org-mandated gates.
- Build stage: Org-mandated gate — container image build + SAST scan + dependency vulnerability scan (fail on Critical CVEs). Team gate — unit tests with ≥80% coverage delta threshold.
- Integration stage: Org-mandated gate — consumer-driven contract tests against the service's published API spec (Pact or equivalent). The gate fails if any registered consumer's contract is broken. Team gate — integration tests against a shared ephemeral environment.
- Staging stage: Org-mandated gate — load test reaching 2× expected peak QPS; p99 latency must stay within SLO. Team gate — smoke tests and synthetic transaction checks.
- Pre-prod (canary launch): The service is deployed to 5% of production traffic. Canary gate evaluates error rate (must not exceed baseline + 0.5 percentage points), p99 latency (must not exceed baseline × 1.2), and business KPI delta (e.g., checkout conversion rate must not drop more than 1% relative to control). If any metric breaches its threshold, the gate triggers an automatic rollback to the previous version. Metrics that are informative but not safety-critical (e.g., cache hit rate, memory usage trending up but within limits) trigger a hold-and-notify — deployment pauses at 5%, alerts the team, and waits for manual promotion or rollback.
- Production (progressive rollout): After canary passes, traffic is ramped 25% → 50% → 100% with the same canary gate re-evaluated at each step. A failure at any step rolls back to the last known-good percentage.
Cross-service dependency gating: Every service publishes an OpenAPI/Protobuf spec in a central schema registry. Before a service can deploy to production, the gate runs backward-compatibility checks — if the new spec removes a required field or changes a type in a breaking way, the gate fails unless all downstream consumers have already deployed a compatible version. The dependency graph is maintained by a service catalog; the gate queries it to identify consumers. Consumer-driven contract tests run at the integration stage and must all pass; the gate blocks if any registered consumer's contract is broken by the new version.
Decentralization with enforced baseline: Gates are defined as code in a shared gate-library repository. Each team's pipeline imports a 'base-gate-profile' that contains the org-mandated gates (SAST, CVE scan, contract tests, load test, canary SLO gate). Teams can add team-specific gates on top but the base profile is enforced by a policy controller (OPA/Conftest) that validates every pipeline definition at commit time — if the base gates are missing or disabled, the pipeline config is rejected by the CI system and cannot run. This gives teams autonomy to extend while guaranteeing the safety floor.
This design exercise tests the candidate's ability to architect a multi-layered deployment-gate system that balances safety with team autonomy. A strong answer covers stage-specific gates with concrete pass/fail criteria, canary rollback signals with numeric thresholds, cross-service dependency validation with an explicit block condition, and a policy-enforced baseline that prevents teams from disabling safety gates while still allowing extension. The rubric was corrected so that c1 (stage taxonomy) and c3 (cross-service dependency gating) no longer both credit consumer-driven contract tests: c1's integration-stage example now references integration tests against an ephemeral environment, while c3 exclusively owns contract tests, schema-compatibility checks, and dependency-graph mechanisms, and additionally requires the candidate to specify the exact block condition — making it discriminating against shallow answers that merely name a technique.
DevOps/ci-cd-practice/deployment-gates
You are designing the deployment pipeline for a financial-services application subject to SOX and PCI-DSS compliance. The business wants to move from monthly releases to weekly production deployments, but compliance requires that every production deployment has an auditable approval trail, separation of duties (the person who builds cannot be the person who approves), and evidence that specific quality gates were met.#
Show answer
Gate taxonomy and automation boundary:
Automated gates (no human action required, evidence captured automatically):
- Build gate: compilation + unit tests + coverage threshold (≥80%). Pass/fail is deterministic.
- Security gate: SAST, DAST, dependency CVE scan, container image scan. Fail on Critical/High.
- IaC gate: Terraform plan validation + policy-as-code check (no public S3 buckets, encryption required, etc.).
- Integration gate: contract tests + integration tests against a staging environment mirroring production config.
- Compliance gate: automated check that the deployment package matches the approved change ticket (e.g., Jira issue linked in the commit), and that all required automated gates have passed with their evidence stored.
Human-approval gate (the only manual step):
- Production release authorization: a designated approver (not the builder) reviews the compiled evidence package — test results, scan reports, change-ticket linkage, artifact hash — and explicitly approves promotion to production. This gate exists because SOX requires management authorization for changes to production financial systems, and a human must attest that the change was reviewed.
Separation of duties enforcement: The CI/CD platform enforces two disjoint RBAC roles: 'Deployer' (can trigger pipeline runs, merge code, push artifacts through staging) and 'Approver' (can authorize production promotion). The pipeline's production-promotion step checks the identity of the approver against the identity of the user who triggered the current pipeline run. If they match, the step is blocked and returns an error. Additionally, pull requests require at least one review from a member of the Approver group before merge, and the PR system prevents self-review. These are enforced by the platform (e.g., pipeline engine identity checks + SCM branch-protection rules), not by verbal policy.
Compliance evidence capture: Every gate — automated and manual — writes a structured evidence record to an immutable, append-only audit store (e.g., a dedicated evidence repository or a tamper-evident log service). Each record contains: gate name, gate version/config hash, input artifact hash, pass/fail result, detailed output (test report, scan findings), timestamp (UTC, from a trusted time source), and the identity that triggered or approved it. Records are correlated by a deployment ID that links every gate result to the specific artifact hash and change ticket. An auditor can query by deployment ID or date range and receive a complete, ordered timeline of every gate executed, its result, and who acted. The audit store uses hash-chaining (each record references the hash of the previous record) to make tampering detectable.
Bottleneck reduction: (1) The human approver never runs tests or scans manually — by the time approval is requested, all automated gates have passed and the evidence package is pre-assembled. The approver reviews a summary dashboard with green/red indicators and drill-down links, taking 2–5 minutes. (2) Production rollout uses canary delivery: the approver authorizes a 5% canary, automated health gates evaluate metrics for 15 minutes, and if they pass, the rollout auto-promotes to 100% without a second human approval. The human is in the loop once, not at every step. (3) For low-risk changes (documentation, non-functional config via feature flags), an expedited path auto-approves if the change classifier determines the diff touches only flag-config files — the compliance gate still records all evidence and the auto-approval decision with its rationale.
This exercise tests the candidate's ability to design deployment gates that satisfy regulatory compliance (SOX/PCI-DSS) without reintroducing slow manual release processes. A strong answer distinguishes automated from human gates with rationale, enforces separation of duties through technical controls, captures tamper-evident audit evidence, and uses techniques like pre-assembled evidence packages and canary delivery to minimize human bottleneck.
DevOps/ci-cd-practice/deployment-gates
You run a continuous delivery pipeline for a polyglot microservices platform where several services share a common PostgreSQL database (not ideal, but it's the current state). Database schema migrations are a frequent source of deployment failures and production incidents — breaking changes, long-running ALTER TABLE locks, and migrations that succeed in staging but fail in production due to data volume differences.#
Show answer
Breaking-change detection and expand-contract enforcement:
The gate includes a migration analyzer that parses each migration script (or diffs the before/after schema) and classifies every DDL operation:
- Breaking: DROP COLUMN, DROP TABLE, RENAME COLUMN, type narrowing (VARCHAR(255) → VARCHAR(50)), adding NOT NULL constraint without a default, removing a default.
- Non-breaking: ADD COLUMN (nullable or with default), ADD INDEX (using CONCURRENTLY), widening types, adding a table.
When the gate detects a breaking change, it checks the migration history and the currently-deployed application code version. For a DROP COLUMN, the gate requires that: (a) a prior migration added the replacement column, (b) the currently-deployed code version no longer references the old column (verified by checking that the deployed artifact's schema-config or ORM mapping doesn't include it), and (c) at least one full deployment cycle has passed since the expand migration. If any condition is unmet, the gate blocks the migration with a message like 'Contract phase blocked: column X still referenced by deployed code version Y.' This enforces expand-then-contract by making the gate stateful — it tracks which expand migrations have been deployed and only permits the corresponding contract migration after code deployment is verified.
Production-scale performance validation:
The gate does not trust staging data volume. Instead, it runs the migration against a production-sized data clone — a logical replica of production created from the latest PITR snapshot, restored to a disposable compute instance. The migration is executed against this clone with instrumentation: the gate captures wall-clock time, lock-wait time, and whether any statement holds an AccessExclusiveLock for more than a configurable threshold (e.g., 5 seconds). If the migration exceeds the time threshold or acquires a blocking lock, the gate fails and suggests an alternative (e.g., use CREATE INDEX CONCURRENTLY, or batch the UPDATE). For very large tables, the gate also runs EXPLAIN ANALYZE on destructive statements to estimate row-scan costs. The clone is sized to match production's largest table row counts, closing the staging-vs-production gap.
Migration-application deployment ordering:
The gate enforces ordering through a deployment manifest that each service submits with its pipeline. The manifest declares the migration type (expand, contract, or none) and the code compatibility level (backward-compatible with old schema, requires new schema). The gate enforces:
- If the migration is 'expand' (additive): migration runs first, then new code is deployed. Old code remains compatible because the migration is additive.
- If the migration is 'contract' (removing old schema): the gate verifies the currently-deployed code is the backward-compatible version from the expand phase, then runs the contract migration, then (optionally) deploys code that assumes the old schema is gone.
- If no migration: standard code deployment. The pipeline engine refuses to proceed if the manifest's declared ordering doesn't match the gate's classification — e.g., if a team labels a DROP COLUMN migration as 'expand,' the analyzer catches the mismatch and blocks.
Rollback safety:
The gate classifies each migration as reversible or irreversible at analysis time:
- Reversible: ADD COLUMN (nullable), ADD INDEX, CREATE TABLE. These can be rolled back with DROP, and no committed data is lost (the column was new).
- Irreversible: DROP COLUMN (data in that column is destroyed), DROP TABLE, TRUNCATE, type narrowing (data may be truncated).
Policy: When a deployment fails after a migration has been applied, the system checks the migration's reversibility classification. If reversible, the migration is rolled back and the previous code version is redeployed. If irreversible, the system rolls back the code to the previous version but leaves the schema change in place — rolling back the migration would cause data loss. The incident is flagged for a forward-fix: the team must fix and redeploy rather than revert the schema. The gate also requires that all contract-phase migrations are preceded by a verified backup or that the data being removed has been archived — the gate checks for an archive artifact (e.g., a dump of the column's data stored in object storage) before permitting an irreversible migration to proceed.
This exercise tests the candidate's ability to design a database-migration gate that prevents schema-related deployment failures. A strong answer includes static analysis for breaking changes with expand-contract enforcement, production-scale performance validation that closes the staging-vs-production data gap, enforced migration-code deployment ordering, and a rollback policy that distinguishes reversible from irreversible migrations to prevent data loss.
DevOps/ci-cd-practice/pipeline-as-code
You are the platform engineer responsible for a large monorepo shared by 12 product teams. Each team currently maintains its own Jenkinsfile, and the CI pipeline definitions have diverged wildly—some teams run tests in parallel, some not at all; secret handling ranges from hardcoded env vars to proper vault integration; and average CI runtime is 35 minutes. Leadership wants you to migrate everything to a single pipeline-as-code standard that lives in the repo itself, reduces average CI time by 50%, and enforces a shared security baseline while still letting each team customize build/test steps. The target CI/CD platform is GitHub Actions (you may use reusable workflows, composite actions, and matrix strategies). Design the pipeline-as-code architecture. Address: (1) how the shared pipeline skeleton and per-team customization points are structured in code, (2) how secrets are injected securely and uniformly, (3) how you achieve the 50% runtime reduction (caching, parallelism, selective execution), and (4) how you roll out the standard across 12 teams without a big-bang migration.#
Show answer
We introduce a single reusable workflow at .github/workflows/ci.yml that acts as the shared entry point for every team's pull request and push events. This reusable workflow calls a set of composite actions organized by concern: setup (toolchain + caching), security-scan (SAST, dependency scanning, secret detection), build, test, and publish. Per-team customization is achieved through convention-based discovery: each team's package directory contains a .ci/build.sh and .ci/test.sh (or a ci-config.yml declaring custom steps). The reusable workflow dynamically includes these scripts at the appropriate stage using working-directory and conditional job steps. Teams that need entirely custom logic can supply a composite action at packages/<team>/.ci/custom-action/ that the shared workflow invokes if present, keeping the security baseline (SAST, dependency scanning) non-negotiable while allowing build/test flexibility.
Secrets are managed centrally: organization-level secrets store shared credentials (e.g., artifact store, vault endpoint), and per-team secrets are scoped to GitHub Environments mapped to each package path via deployment-environment naming conventions. For sensitive infrastructure, we federate with OIDC to HashiCorp Vault, issuing short-lived, per-team roles so no static credentials live in GitHub. The reusable workflow references ${{ secrets.* }} only through the environment-scoped injection, preventing teams from accessing each other's secrets.
Runtime reduction comes from three techniques. First, dependency and build-output caching via actions/cache keyed on lockfile hashes, plus Docker layer caching for containerized builds. Second, selective execution: we use dorny/paths-filter or tj-actions/changed-files to detect which packages changed and dynamically generate a matrix of only the affected packages, skipping build/test for unchanged areas. Third, test parallelism: each package's test suite is split into shards using a matrix strategy (e.g., shard: [1/4, 2/4, 3/4, 4/4]) with a test-splitter tool, and independent packages run concurrently as separate matrix entries.
Rollout is phased: we start with two pilot teams, running the new GitHub Actions pipeline in shadow mode alongside their existing Jenkinsfile for two weeks. We compare results and timing, then publish a migration checklist (provide .ci/ scripts, declare environment mappings, validate secret access). Each subsequent team migrates one sprint at a time, with a 1-week overlap period where both pipelines run. A migration tracking dashboard (built from workflow run data) shows which teams have migrated, their CI time delta, and any failing checks. Legacy Jenkinsfiles are archived (not deleted) only after a team's new pipeline has been green for two consecutive weeks, preventing a big-bang failure.
This design exercise tests senior-level pipeline-as-code architecture: structuring reusable workflows with controlled customization, centralized secret injection, concrete monorepo-specific runtime optimizations, and a realistic phased rollout. Difficulty 4 because it requires synthesizing GitHub Actions primitives (reusable workflows, composite actions, matrix strategies, environments/OIDC) with organizational concerns (12 teams, divergence, incremental migration) and quantifiable targets (50% runtime reduction).
DevOps/ci-cd-practice/pipeline-stages
A monorepo team has a linear CI/CD pipeline: Build → Unit Tests → Integration Tests → Security Scan (SAST) → Build Docker Image → Deploy to Staging → E2E Tests → Deploy to Production. Pipeline wall-clock time is 25 minutes and developers frequently wait for the full run before getting feedback. The team wants to reduce feedback time without weakening deployment confidence. Which redesign is the soundest approach?#
Options
Show answer
Build the deployment artifact once, run fast feedback gates (lint, unit tests) first, then parallelize independent slower checks (integration tests, SAST) after those pass, and promote the same image through staging and production. This follows fail-fast sequencing and build-once-promote-everywhere: you get early signal on cheap failures, avoid redundant rebuilds, and guarantee the tested artifact is the one deployed.
Option B applies two well-established CI/CD principles. First, fail-fast: cheap, high-signal checks (lint, unit tests) run before expensive ones (integration tests, SAST), so a trivial failure is caught in seconds rather than after waiting for slower parallel jobs to finish — which is why option A (parallelizing everything immediately) wastes compute and delays the most common feedback. Second, build-once-promote-everywhere: the artifact tested in later stages is the exact artifact deployed to production, which option C violates by rebuilding per environment (breaking traceability and the guarantee that the tested image is the deployed image). Option D collapses distinct gates into one, losing granular feedback on which check failed and removing the ability to short-circuit early on a fast failure. Option B preserves the same artifact across stages while sequencing fast gates before slow ones and parallelizing only the independent slow checks that remain.
DevOps/ci-cd-practice/deployment-gates
You are the platform lead for a large-scale microservices platform serving 50M+ daily active users across multiple regions. Each service deploys independently 5-20 times per day. Leadership wants to move from manual pre-production approvals to an automated progressive delivery system with canary analysis, but the platform must satisfy two hard constraints: (1) any deployment that causes a regression in user-facing SLOs must auto-rollback within 90 seconds of the regression becoming statistically detectable, and (2) the system must support per-service customization of gate logic while enforcing platform-wide safety invariants (e.g., no service can skip the canary stage).#
Show answer
The deployment pipeline progresses through these gates: (1) Commit gate — CI builds the artifact, runs unit tests and SAST; (2) Integration gate — deploys to a staging cluster and runs integration and contract tests; (3) Canary gate — deploys to 1% of traffic in a single AZ in the primary region with a 5-minute soak; (4) Progressive rollout gates — traffic shifts through 5%, 25%, 50%, and 100% in the primary region with a 10-minute soak and gate evaluation at each stage; (5) Multi-region gates — repeat stages 3-4 region-by-region in a defined order (primary → secondary → edge regions).
Complete gate pipeline from commit to production (c1): Every change starts at the commit gate, where CI builds the container image, runs unit tests, executes SAST/DAST scans, and publishes a signed artifact to the registry. Only a passing commit gate triggers the integration gate, which deploys the artifact to a staging cluster that mirrors production topology (minus scale) and runs integration tests, consumer-driven contract tests, and schema-compatibility checks. A failing integration gate blocks the artifact from ever reaching production traffic. Only after both pre-deployment gates pass does the system proceed to the canary gate, ensuring no code reaches live traffic without automated pre-deployment validation.
Canary SLI selection and baseline comparison (c2): Each service declares its SLIs via a policy file: error rate (HTTP 5xx / total requests), p99 latency, and saturation (CPU and connection pool utilization). The baseline is the previous deployed version running concurrently in the same environment. The platform collects metrics for both the canary and baseline cohorts using the same observability stack (e.g., Prometheus with canary/baseline labels injected by the service mesh). The comparison is relative: canary error rate must not exceed baseline by more than the service-defined tolerance.
Statistical rollback decision boundary (c3): The platform uses sequential hypothesis testing (specifically, a sequential probability ratio test, SPRT) on the error-rate delta between canary and baseline. Parameters: minimum sample size of 10,000 requests per cohort before evaluation begins; significance threshold of p < 0.01 for rollback (null hypothesis: canary error rate ≤ baseline); evaluation window of 60 seconds sampled every 10 seconds. If at any sample the SPRT rejects the null hypothesis (canary is worse), the system triggers automatic rollback. If after the full soak period the SPRT has not rejected the null and the canary is not worse, the gate promotes to the next traffic stage. A secondary check on p99 latency uses a non-inferiority test: canary p99 must not exceed baseline p99 by more than 10ms with 95% confidence. If either check fails, rollback fires. The 10-second sampling interval combined with the SPRT's sequential nature means that once statistical power is reached (minimum sample size met), a regression is detected and rollback initiated within the 90-second window.
Progressive traffic-shifting stages with soak gates (c4): Traffic shifts via the service mesh load balancer: 1% (5-min soak) → 5% (10-min soak) → 25% (10-min) → 50% (10-min) → 100% (10-min). At each stage boundary, the gate evaluates all SLIs using the same SPRT. If any gate fails, traffic is immediately shifted back to 0% for the canary version (full rollback to previous version) and the deployment is marked failed with an alert to the owning team. The soak times are minimums; the gate cannot advance until both the soak time has elapsed and the SPRT has not triggered rollback.
Blast radius containment (c5): Two mechanisms limit impact. First, sticky-session routing: users assigned to the canary cohort are pinned via a cookie or consistent hash so that the canary population is stable and does not rotate new users in during evaluation — this means at most 1% of users are exposed at the first canary stage. Second, single-AZ canary: the initial canary deploys to one AZ in one region, so a canary failure affects at most one AZ's worth of traffic in one region, and the mesh health checks drain the canary instances within seconds. On rollback, the service mesh removes canary endpoints from the load balancer pool; existing canary sessions are redirected to baseline instances. For stateful services, session draining waits for in-flight requests to complete (up to a 30-second drain timeout) before terminating canary instances.
Per-service customization with enforced platform invariants (c6): Services define their gate policy in a YAML file versioned alongside their code: custom SLIs (e.g., a payment service might add a 'payment success rate' SLI), custom thresholds (tolerance for error-rate delta, latency budget), and pre-deploy checks (e.g., a database migration dry-run). The platform loads this policy but applies a platform-level override layer that enforces non-negotiable invariants: the canary stage cannot be skipped or disabled; minimum soak times cannot be set below platform-defined floors (5 min for canary, 10 min for progressive stages); the SPRT significance threshold cannot be weakened below p < 0.01; and the rollback action is always platform-controlled (services cannot override the rollback trigger). If a service's policy conflicts with an invariant, the platform rejects the policy at the integration gate and the deployment cannot proceed. This model lets services customize their sensitivity while the platform guarantees that no service can weaken safety below the floor.
Multi-region rollout failure handling (c7): During multi-region rollout, each region runs its own independent canary and progressive stages. If region B's canary fails, region B rolls back immediately and independently — its traffic returns to the previous version without waiting for any cross-region coordination. The platform then pauses the rollout to all remaining un-deployed regions (region C, D, etc.) to prevent propagating a potentially broken build. Region A (already promoted to 100%) is not automatically rolled back. Instead, the platform raises a high-severity alert and surfaces the region B failure analysis (which SLIs failed, magnitude of regression, error signatures) to the owning team, who must explicitly decide whether to rollback region A. This alert-and-halt approach is chosen over automatic multi-region rollback because the failure signal in region B may be region-specific (e.g., a regional dependency outage, a data residency edge case) and would not necessarily reproduce in region A. An unnecessary multi-region rollback of healthy regions carries its own blast radius — it disrupts users currently served by the new (and apparently healthy) version in region A and consumes deployment capacity. The platform provides a one-click rollback for region A and, if the team identifies the failure as a global code defect, a single action to rollback all regions simultaneously.
This is a staff-level design exercise requiring the candidate to integrate progressive delivery, statistical canary analysis, blast-radius engineering, and policy-as-code extensibility into a coherent system with hard performance constraints (90-second rollback) and organizational tensions (per-service customization vs. platform safety invariants). The rubric now covers all seven areas the prompt explicitly requires: the full commit-to-production gate sequence, SLI/baseline selection, statistical decision boundaries, progressive traffic shifting, blast radius containment, customization with invariants, and multi-region failure handling.
DevOps/ci-cd-practice/deployment-gates
You are the DevOps platform owner for a fintech company operating under PCI-DSS and SOX compliance. The engineering organization has 40 teams working in a monorepo with 200+ deployable services. Some teams deploy multiple times per day; others deploy weekly. The compliance team requires that every deployment to production produce an immutable, auditable evidence package proving that all required gates passed (SAST, dependency vulnerability scan, peer review, manual change-approval for SOX-scoped services, and successful regression tests). The evidence must be retained for 7 years and producible on-demand for an external auditor within 24 hours.#
Show answer
The framework consists of four components: a service registry, a policy engine, a pipeline orchestrator, and an evidence store.
Monorepo to per-service pipeline mapping (c1): The monorepo contains a build-time dependency graph maintained via a tool like Bazel or Nx. When a PR is merged, a CI job analyzes the changed files, resolves the reverse dependency graph, and determines which deployable services are affected. Each affected service triggers its own independent deployment pipeline with its own build artifact (container image), identified by a content-addressable hash (e.g., SHA-256 of the image digest). Unaffected services are not deployed. This allows 40 teams to deploy independently from a shared monorepo without cross-team blocking.
Compliance-gate routing by service classification (c2): A service registry (a YAML manifest in the monorepo at a well-known path) classifies each service with compliance tags: sox-scoped: true/false, pci-scoped: true/false, and a criticality level. The policy engine reads the registry at pipeline start and selects the gate set. For example: a SOX-scoped payment service runs SAST, dependency vulnerability scan, unit tests, integration tests, regression suite, peer review (codeowner approval on the PR), and delegated production approval. A non-scoped internal tooling service runs SAST, dependency scan, unit tests, and peer review only — no production approval gate. A PCI-scoped service additionally runs a PCI-DSS configuration check (e.g., verifying encryption-at-rest settings) and requires a quarterly-access-review attestation gate. The classification is itself version-controlled and peer-reviewed, so changing a service's scope requires a PR that the compliance team must approve via CODEOWNERS.
Immutable evidence collection and cryptographic signing (c3): Each gate produces a structured evidence record: gate name, service name, artifact hash, pass/fail status, test output (JUnit XML or log URL), approver identity (from the identity provider, not a username string), timestamp, and gate version. The orchestrator collects all evidence records for a deployment into a single evidence package. The package is serialized as an in-toto attestation (SLSA Level 3 provenance) and signed using a signing key held in a cloud KMS (e.g., AWS KMS or GCP KMS) with key rotation every 90 days. The signed package is written to a WORM (write-once-read-many) object storage bucket with a 7-year retention lock — objects cannot be deleted or overwritten by any identity, including root. The KMS public key is published so auditors can independently verify signatures. To produce evidence within 24 hours, an auditor portal queries the evidence store by service name and date range, retrieves the signed packages, verifies signatures client-side, and exports a compliance report.
Decentralized approval replacing the CAB (c2/c4): The centralized CAB is replaced with a delegated approval model. Each SOX-scoped service has a designated set of approvers (minimum two individuals, configured in CODEOWNERS). For a production deployment, the pipeline automatically approves if: (a) all automated gates pass, (b) the PR has been reviewed and approved by at least one codeowner who is NOT the PR author (segregation of duties), and (c) the deployment falls outside a freeze window. No separate CAB review is needed because the codeowner approval serves as the change authorization, and the automated gates serve as the risk assessment. The evidence package records the approver's identity, the PR approval timestamp, and a hash of the approved diff — satisfying SOX's requirement for documented change authorization with accountable approver identity. For PCI-scoped services, a quarterly review confirms that the approver list is current and that no approver has access to production systems they approve changes for (segregation of duties). The compliance team audits the evidence store quarterly by sampling deployments and verifying that the recorded approvals match the actual PR approvals and that no deployment bypassed a mandatory gate.
Deployment freeze enforcement and custom gate extensibility (c5): A central deployment calendar (a versioned YAML file maintained by the release management team) defines freeze windows: end of financial quarter (last 7 days), regulatory filing periods, and incident-driven freezes (triggered by an on-call SRE via a CLI command that sets a global freeze flag). The orchestrator checks the calendar before the production-deployment gate; if a freeze is active for the service's scope, the gate fails with a 'deployment frozen' status and the pipeline halts. Emergency hotfixes during a freeze require a break-glass approval: the on-call SRE and a compliance officer both approve via a signed break-glass request (recorded as an evidence entry with both approver identities and a justification string), and the deployment proceeds with a post-hoc review scheduled within 48 hours.
Teams extend the framework with custom gates via a plugin interface: each service can declare custom gates in its pipeline configuration (e.g., license-scan, cost-budget-check, schema-compatibility-check). Custom gates are implemented as containerized jobs that emit the same evidence record format. The framework enforces that custom gates run AFTER all platform-mandatory gates and cannot be configured to run before or replace them. The platform-mandatory gate list is defined in the policy engine's core configuration, which is owned by the platform team and cannot be modified by service teams. If a custom gate fails, the deployment is blocked — but if a custom gate passes incorrectly due to a bug, the platform-mandatory gates still provide the compliance floor. A service cannot remove or reorder platform-mandatory gates; the policy engine rejects any pipeline configuration that attempts to do so.
This is a staff-level exercise requiring the candidate to design a deployment gate framework that simultaneously solves monorepo-to-service pipeline mapping, compliance-gate routing, cryptographic evidence provenance, decentralized approval architecture (replacing a CAB while satisfying SOX/PCI), freeze enforcement, and safe extensibility — all under regulatory audit constraints with 7-year retention and 24-hour evidence retrieval SLAs.
DevOps/ci-cd-practice/pipeline-stages
A team delivers a microservice with three independent control planes:#
Options
Show answer
The correct approach is to test the new endpoint with the feature flag ON in both the CI integration test and the CD staging smoke test (using a staging-only override), then enable the flag for production users via the runtime feature-flagging service after canary promotion completes — independently of the CD pipeline. This ensures the new code is exercised at every level before production exposure while keeping deployment (pipeline) and release (flag toggle) as separate control planes.
Option B is the only approach that satisfies every stated requirement. The CI integration test with the flag ON exercises the new code path at the build/test level. The CD staging smoke test with the flag ON (via a staging-only environment override) exercises the new code path in a production-like environment before any production user is exposed. The flag is enabled for production users through the runtime feature-flagging service — independently of the CD pipeline — after canary promotion to 100% succeeds, preserving the separation between deployment (infrastructure/code placement) and release (making functionality available to users).
Option A fails because the staging smoke test runs with the flag OFF, so the new code path is never exercised in staging — only in CI.
Option C fails for the same reason: no staging smoke test for the new endpoint means the new code path is validated only in CI, not in a production-like environment.
Option D fails on two counts: the CI integration test runs with the flag OFF, so the new code path is never exercised in CI; and enabling the flag as a step within the deploy-to-staging pipeline stage couples the release decision (flag toggle) to the deployment process, violating the required separation between deployment and release.
DevOps/ci-cd-practice/build-artifacts
In a distributed, multi-node CI build system using remote build caching (e.g. Bazel remote execution or Buildkit's cache exporter), what is the key design principle that makes build artifact cache hits safe across heterogeneous worker nodes with different OS kernels and CPU architectures, and how is it enforced?#
Show answer
Use a content-addressable storage (CAS) model keyed on the hash of inputs (source + toolchain + env vars + transitive deps), not on branch/commit alone. Bazel and Buck2 exemplify this: the build graph is hermetically sealed (all inputs explicitly declared), outputs are stored by their content hash, and remote execution nodes share a CAS-backed cache. A cache hit on node A is therefore deterministic on node B because the hash captures the full input set—toolchain version, compiler flags, env var values, and dependency hashes—making locality irrelevant.
This tests staff-level understanding of hermetic, content-addressable build systems—the foundation of safe remote caching. The key insight is that correctness of cross-node cache hits depends on hashing the entire input closure (including toolchain, flags, env, transitive deps), not just source. Without hermeticity, a cache hit on one node may reflect a different effective toolchain or environment, producing non-reproducible artifacts. Systems like Bazel enforce this through declared inputs and sandboxed execution.
Related interview questions
The other 1 question
This page shows 25. A free account opens the rest and marks your answers, which a page of answers can't do. Miss one and it returns a few days later, then a week after that, until you stop missing it.
Free · the whole bank · 100 graded answers per 30 days · written feedback and job-ad quizzes on the paid plan