# CI/CD Pipeline Template Save as `_docs/04_deploy/ci_cd_pipeline.md`. --- ```markdown # [System Name] — CI/CD Pipeline ## Pipeline Overview | Stage | Trigger | Quality Gate | |-------|---------|-------------| | Lint | Every push | Zero lint errors | | Test | Every push | 75%+ coverage, all tests pass | | Security | Every push | Zero critical/high CVEs | | Build | PR merge to dev | Docker build succeeds | | Push | After build | Images pushed to registry | | Deploy Staging | After push | Health checks pass | | Smoke Tests | After staging deploy | Critical paths pass | | Deploy Production | Manual approval | Health checks pass | ## Stage Details ### Lint - [Language-specific linters and formatters] - Runs in parallel per language ### Test - Unit tests: [framework and command] - Blackbox tests: [framework and command, uses docker-compose.test.yml] - Coverage threshold: 75% overall, 90% critical paths - Coverage report published as pipeline artifact ### Security - Dependency audit: [tool, e.g., npm audit / pip-audit / dotnet list package --vulnerable] - SAST scan: [tool, e.g., Semgrep / SonarQube] - Image scan: Trivy on built Docker images - Block on: critical or high severity findings ### Build - Docker images built using multi-stage Dockerfiles - Tagged with git SHA: `/:` - Build cache: Docker layer cache via CI cache action ### Push - Registry: [container registry URL] - Authentication: [method] ### Deploy Staging - Deployment method: [docker compose / Kubernetes / cloud service] - Pre-deploy: run database migrations - Post-deploy: verify health check endpoints - Automated rollback on health check failure ### Smoke Tests - Subset of blackbox tests targeting staging environment - Validates critical user flows - Timeout: [maximum duration] ### Deploy Production - Requires manual approval via [mechanism] - Deployment strategy: [blue-green / rolling / canary] - Pre-deploy: database migration review - Post-deploy: health checks + monitoring for 15 min ## Caching Strategy | Cache | Key | Restore Keys | |-------|-----|-------------| | Dependencies | [lockfile hash] | [partial match] | | Docker layers | [Dockerfile hash] | [partial match] | | Build artifacts | [source hash] | [partial match] | ## Parallelization [Diagram or description of which stages run concurrently] ## Notifications | Event | Channel | Recipients | |-------|---------|-----------| | Build failure | [Slack/email] | [team] | | Security alert | [Slack/email] | [team + security] | | Deploy success | [Slack] | [team] | | Deploy failure | [Slack/email + PagerDuty] | [on-call] | ```