CI/CD Flashcards

(69 cards)

1
Q

CI vs CD: What is CI?

A

Continuous Integration: frequently integrating changes into main with automated validation (build, unit tests, lint/static checks). Goal: main stays in a deployable state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

CI vs CD: What is CD (Delivery)?

A

Continuous Delivery: every change passes the pipeline and is ready to deploy; production deploy may require manual approval.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

CI vs CD: What is Continuous Deployment?

A

A form of CD where every change that passes the pipeline is automatically deployed to production (less common in many orgs).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why do teams use CI/CD pipelines?

A

To automate quality checks, reduce human error, speed up delivery, ensure consistency/repeatability, and make deployments safer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Pipeline mental model

A

A production line: checkout → build → test → quality gates → package → publish artifact → deploy (dev/staging/prod) → post-deploy checks/monitoring.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a pipeline stage?

A

A logical step in the automated workflow (e.g., build, unit tests, integration tests). Stages help isolate failures and enforce gates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Typical CI stage: Checkout

A

Pull the correct version of source code from the repository to the runner/agent so the build can run reproducibly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Typical CI stage: Build (Java)

A

Compile and package the app (e.g., mvn package / gradle build). Ensures code compiles and dependencies resolve.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Typical CI stage: Unit tests

A

Fast, isolated tests (no real DB/network). Provide quick feedback and catch logic regressions early.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Typical CI stage: Integration tests

A

Tests that run with real components (e.g., DB in container, Spring context). Catch wiring/config/contract issues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a quality gate?

A

Automated checks that must pass before merging/deploying (lint, static analysis, coverage thresholds, security scans).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an artifact in CI/CD?

A

The immutable build output (e.g., JAR, Docker image). Best practice: build once, deploy the same artifact across environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why ‘build once, deploy same artifact’?

A

Prevents environment-specific differences, improves reproducibility, and makes debugging/rollbacks safer because you know exactly what ran in each env.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is promotion (artifact promotion)?

A

Moving the same artifact through environments (dev → staging → prod) after it passes validations in each stage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why do we have environments (dev/staging/prod)?

A

Dev for rapid iteration, staging to validate in prod-like conditions, prod for real users. Separates risk and allows progressive validation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What should usually run in CI?

A

Build, unit tests, fast static checks, quick security scans. The goal is fast feedback on every PR/commit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What should usually run in CD?

A

Packaging/publishing artifacts, deployments to environments, smoke tests, post-deploy checks, approvals for prod.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a smoke test?

A

A small set of fast tests that verify the deployed service is basically working (health endpoint, a key API call, DB connectivity).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a rollback?

A

Returning to a known-good version after a bad deployment, often by redeploying the previous artifact.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Simple rollback strategy

A

Redeploy the last known-good artifact/version. Works well when artifacts are versioned and deployments are automated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Blue/Green deployment

A

Maintain two environments (blue and green). Deploy to inactive one, switch traffic when healthy. Rollback = switch traffic back.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Canary deployment

A

Deploy to a small percentage of users/traffic first. Monitor metrics. If healthy, ramp up; if not, stop/rollback.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Feature flags: why useful?

A

Ship code disabled, enable gradually. Reduces risk, allows quick disable without redeploy, supports experiments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a runner/agent?

A

The machine/container that executes pipeline jobs (Jenkins agent/node or GitHub Actions runner).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Jenkins vs GitHub Actions: Jenkins overview
Flexible CI server; pipelines defined in Jenkinsfile; requires more operational maintenance; uses agents/nodes and credentials store.
26
Jenkinsfile: what is it?
A file defining the Jenkins pipeline (stages/steps). Can be Declarative or Scripted.
27
GitHub Actions: workflow structure
YAML defines workflows → jobs → steps. Jobs run on runners; supports matrices, caching, environments, and secrets.
28
GitHub Actions: what is a job?
A set of steps executed on the same runner. Jobs can run in parallel and depend on each other.
29
GitHub Actions: what is a step?
A single action/command within a job (e.g., checkout code, run tests, build artifact).
30
What is caching in CI?
Reusing dependencies/build outputs between runs to speed up builds (e.g., Maven/Gradle dependency cache).
31
Why are flaky tests bad?
They fail intermittently without real regressions, wasting time, reducing trust in CI, and slowing delivery.
32
Common causes of flaky tests
Time dependence, ordering dependence, shared state, network calls, race conditions, unstable external services.
33
How to reduce flaky tests
Remove real network dependencies, control time, isolate state, deterministic data, proper waiting/timeouts, quarantine and fix root causes.
34
What is 'works on my machine' in CI/CD context?
Local environment differs from CI (Java version, env vars, DB schema). Fix by standardizing environments and making builds reproducible.
35
Common reasons a pipeline fails
Test failures, missing env vars/secrets, expired credentials, dependency conflicts, DB migration issues, timeouts.
36
How to debug a pipeline failure (process)
Identify the failing stage → read logs → reproduce locally if possible → isolate root cause (code vs config vs infra) → fix → add prevention (tests/alerts).
37
What is a quality gate example for Java?
Checkstyle/Spotless formatting, SpotBugs, SonarQube rules, minimum coverage threshold, dependency vulnerability scan.
38
What is SAST?
Static Application Security Testing: scans code for security issues (e.g., insecure patterns) during CI.
39
What is dependency scanning (SCA)?
Software Composition Analysis: scans dependencies for known vulnerabilities/licenses and can fail builds if risk is high.
40
What are pipeline approvals used for?
To control risk for sensitive steps (like prod deploy). Adds a manual gate even if everything else is automated.
41
Why separate unit vs integration tests in pipeline?
Unit tests give fast feedback; integration tests are slower but catch environment/config issues. Separation speeds PR iteration.
42
What is artifact versioning?
Tagging build outputs with unique versions (commit SHA, semantic version). Enables traceability, rollback, and consistent promotion.
43
What does 'immutable artifact' mean?
Once built and published, the artifact should never change. A given version always corresponds to the same bits.
44
What is 'configuration vs code' separation?
Same code/artifact in all environments; environment-specific config is injected via variables, config files, or secret managers.
45
How should secrets be handled?
Never in repo. Inject at runtime via Jenkins credentials, GitHub Secrets, or cloud secret managers; apply least-privilege IAM.
46
What is least privilege?
Give systems/users only the permissions they need—reduces blast radius if credentials leak or systems are compromised.
47
CI/CD + database migrations: why risky?
Schema changes can break running code. You need backward compatibility and controlled rollout.
48
Safe migration pattern (backward compatible)
Add nullable column → deploy code that writes both → backfill → switch reads → add constraints later (NOT NULL/unique) when safe.
49
Why avoid destructive DB changes in one deploy?
Dropping/renaming columns can break older app versions during rollout or rollback. Prefer phased, compatible changes.
50
What is a post-deploy verification step?
Checks after deploy (smoke tests, health checks, monitoring dashboards) to confirm service health and catch issues early.
51
What is a health check endpoint?
An endpoint (e.g., /health) that reports service status; used by orchestration and monitoring to detect failures.
52
What metrics are useful post-deploy?
Error rate, latency (p95/p99), throughput, saturation (CPU/mem), DB connection pool usage, and key business metrics.
53
What’s an SLO/SLI (basic)?
SLI: a measured indicator (latency, availability). SLO: target for that indicator (e.g., 99.9% availability). Helps decide rollout/rollback.
54
What is observability’s role in CD?
It validates deployments: you monitor logs/metrics/traces to detect regressions quickly and decide whether to proceed or rollback.
55
Pipeline speed: how to improve safely?
Cache dependencies, run jobs in parallel, optimize test suites, separate slow tests, and avoid rebuilding unchanged components.
56
When should you fail the pipeline?
On compile errors, failed tests, critical quality gate violations, security scans exceeding threshold, or deployment health checks failing.
57
What is a 'deployment gate'?
A condition that must be met to deploy or proceed (approvals, tests, health checks, error budget, change window).
58
What is a CI/CD “stage isolation” benefit?
It tells you exactly where it failed (build vs unit tests vs integration tests) and makes debugging faster.
59
How does CI support code review?
CI runs on PRs to provide automatic validation; reviewers can trust the PR passes tests and quality checks.
60
What is a typical Java/Spring pipeline command set?
Checkout → set Java version → mvn/gradle build → run unit tests → run integration tests → package JAR/Docker image → publish artifact → deploy → smoke tests.
61
How to talk about CI/CD if you didn’t write pipelines directly
Emphasize you can read pipelines, interpret failures, collaborate with DevOps, and propose improvements (quality gates, faster feedback, safer deploy).
62
Example CI improvement idea (SE II+)
Split unit and integration tests; make unit tests mandatory on PR, run integration tests on merge to main or nightly if expensive.
63
Example CD safety improvement idea (SE III signal)
Adopt canary/blue-green for critical services, add automatic rollback triggers based on error rate/latency thresholds, and use feature flags.
64
What is a 'release artifact repository'?
A place to store versioned build outputs (e.g., Artifactory, Nexus, container registry). Enables promotion and rollback.
65
Why tag builds with commit SHA?
Traceability: you can map a deployed artifact back to exact source code and investigate regressions.
66
How do approvals relate to compliance?
Some orgs require change control; approvals provide auditable checkpoints for production changes.
67
What is drift between environments?
When environments differ (config, dependencies, schema). Minimizing drift improves reliability and reduces surprises in prod.
68
How do you minimize environment drift?
Use infrastructure-as-code, promote same artifact, externalize config, use containers, and keep schemas aligned via migrations.
69
What is a 'pipeline as code' benefit?
Versioned pipeline definitions (Jenkinsfile/YAML) reviewed via PRs; changes are auditable and reproducible.