Files
skills/public/engineering-ci-cd-pipelines.html
zeekayandHanzo Dev 9e10c1c10e Each llms index points at the other two
hanzoskills.com/llms.txt now opens with the install line, the API
reference index and the company index, so an agent that lands on any
one of the three can find the rest.

robots.txt claimed 537 documents while llms.txt counts 920. The number
is gone from robots.txt; llms.txt derives it.

public/ is regenerated from scripts/site.py, which it had fallen
behind: the copy-prompt menu and agent bar were in the generator and
not in the committed pages. tests/site.mjs passes against the result.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 00:27:59 -07:00

1357 lines
52 KiB
HTML

<!doctype html>
<html lang="en"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>engineering-ci-cd-pipelines</title>
<meta name="color-scheme" content="dark">
<style>
/* Committed to one visual world: a dark instrument panel. No light variant —
the dot field and the hairline rules only read on black, and a naive
inversion would wash both out. Every colour is painted explicitly so the page
never borrows a host background. */
@font-face{font-family:'Zen';src:url('/fonts/Zen-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen';src:url('/fonts/Zen-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Pixel Square';src:url('/fonts/ZenPixel-Square.woff2') format('woff2');font-style:normal;font-display:swap}
:root{
--ink:#f4f4f2; --soft:#9c9c98; --faint:#6a6a66; --ground:#000; --panel:#0a0a0a;
--line:#232323; --line-hi:#3a3a3a; --accent:#f4f4f2;
--font-zen-sans:'Zen',-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
--font-zen-mono:'Zen Mono',ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
--font-zen-pixel-square:'Zen Pixel Square',monospace;
--mono:var(--font-zen-mono);
--sans:var(--font-zen-sans);
/* Controls are pills and surfaces are soft, as on hanzo.ai. */
--r:999px; --r-soft:14px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ground);color:var(--ink);font-family:var(--sans);
font-size:16px;line-height:1.65;-webkit-font-smoothing:antialiased}
.wrap{max-width:60rem;margin:0 auto;padding:0 1.75rem}
/* The dot field. A halftone made of one repeating radial-gradient, faded out
along the diagonal by a mask so it reads as a wave rather than wallpaper. */
/* No overflow clip here: the dot field is inset to the box already, and a clip
would cut off the copy-prompt menu. */
.hero{position:relative;border-bottom:1px solid var(--line)}
.hero::before{content:"";position:absolute;inset:0;
background-image:radial-gradient(var(--line-hi) 1px, transparent 1px);
background-size:7px 7px;
-webkit-mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
pointer-events:none}
.hero .wrap{position:relative;padding-top:5.5rem;padding-bottom:4rem}
nav{border-bottom:1px solid var(--line)}
nav .in{max-width:60rem;margin:0 auto;padding:1.1rem 1.75rem;display:flex;
justify-content:space-between;align-items:center;gap:1rem}
.brand{font-family:var(--mono);font-size:.85rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--ink);text-decoration:none;
display:inline-flex;align-items:center;gap:.6rem}
.brand i{font-style:normal;color:var(--faint)}
.mark{width:1.15em;height:1.15em;display:block;flex:0 0 auto}
nav a.up{font-family:var(--mono);font-size:.72rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--soft);text-decoration:none}
nav a.up:hover{color:var(--ink)}
h1{font-family:var(--mono);font-size:clamp(2rem,5.4vw,3.4rem);line-height:1.12;
letter-spacing:-.02em;margin:0 0 1.1rem;font-weight:500;text-wrap:balance}
h1 em{font-style:normal;color:var(--faint)}
.lede{color:var(--soft);font-size:1.05rem;max-width:52ch;margin:0 0 2.25rem}
.btns{display:flex;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem;align-items:center}
.btn{display:inline-flex;align-items:center;gap:.5rem;font-family:var(--mono);
font-size:.72rem;letter-spacing:.14em;text-transform:uppercase;
padding:.8rem 1.4rem;border:1px solid var(--line-hi);border-radius:var(--r);
color:var(--ink);text-decoration:none;background:transparent;cursor:pointer;
line-height:1.2;font-weight:400}
.btn:hover{background:#141414;text-decoration:none;border-color:var(--soft)}
.btn.solid{background:var(--ink);color:#000;border-color:var(--ink)}
.btn.solid:hover{background:#d8d8d4}
.btn .chev{width:.7em;height:.7em;flex:0 0 auto;transition:transform .15s ease}
.btn[aria-expanded="true"] .chev{transform:rotate(180deg)}
/* Copy-prompt selector. Each row copies the prompt for its own target. */
.copy{position:relative;display:inline-flex}
.menu{position:absolute;top:calc(100% + .5rem);left:0;z-index:20;min-width:21rem;
background:var(--panel);border:1px solid var(--line-hi);border-radius:var(--r-soft);
padding:.4rem;display:flex;flex-direction:column;
box-shadow:0 12px 32px rgba(0,0,0,.75)}
.menu[hidden]{display:none}
.mi{display:flex;align-items:center;gap:.7rem;width:100%;text-align:left;
padding:.62rem .8rem;border:0;border-radius:calc(var(--r-soft) - .35rem);
background:transparent;color:var(--ink);font-family:var(--mono);font-size:.76rem;
letter-spacing:.04em;text-decoration:none;cursor:pointer;line-height:1.3;
white-space:nowrap}
.mi:hover,.mi:focus-visible{background:#181818;outline:none}
.mi .mark{width:1.05rem;height:1.05rem;color:var(--soft)}
.mi:hover .mark{color:var(--ink)}
.mi u{margin-left:auto;color:var(--faint);text-decoration:none;font-size:.68rem;
letter-spacing:.1em;text-transform:uppercase}
/* Works-with bar: one scrolling row, name and mark per agent. */
.strip{border-bottom:1px solid var(--line);background:var(--panel)}
.strip .in{max-width:60rem;margin:0 auto;padding:.9rem 1.75rem;display:flex;
align-items:center;gap:1.25rem;font-family:var(--mono);font-size:.72rem;
letter-spacing:.1em;text-transform:uppercase;color:var(--faint)}
.strip b{color:var(--soft);font-weight:400;flex:0 0 auto;
border-right:1px solid var(--line);padding-right:1.25rem;align-self:stretch;
display:flex;align-items:center}
.bar{display:flex;align-items:center;gap:.5rem;flex:1 1 auto;min-width:0;
overflow-x:auto;scrollbar-width:none;scroll-snap-type:x proximity;
-webkit-overflow-scrolling:touch;
-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent);
mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent)}
.bar::-webkit-scrollbar{display:none}
.agent{display:inline-flex;align-items:center;gap:.45rem;flex:0 0 auto;
padding:.4rem .85rem;border:1px solid var(--line);border-radius:var(--r);
color:var(--soft);white-space:nowrap;scroll-snap-align:start;
text-decoration:none;background:var(--ground)}
.agent:hover{color:var(--ink);border-color:var(--line-hi);text-decoration:none}
.agent .mark{width:.95rem;height:.95rem}
h2{font-family:var(--mono);font-size:1.1rem;letter-spacing:-.01em;margin:2.75rem 0 .75rem;font-weight:500}
h3{font-size:1rem;margin:2rem 0 .5rem;font-weight:600}
h4,h5,h6{font-size:.94rem;margin:1.5rem 0 .5rem;font-weight:600}
p{margin:0 0 1rem;max-width:70ch}
ul,ol{margin:0 0 1rem;padding-left:1.35rem;max-width:70ch}
li{margin:.22rem 0}
a{color:var(--ink);text-decoration:underline;text-underline-offset:3px;
text-decoration-color:var(--line-hi)}
a:hover{text-decoration-color:var(--ink)}
a:focus-visible{outline:1px solid var(--ink);outline-offset:3px}
code{font-family:var(--mono);font-size:.85em;background:var(--panel);
border:1px solid var(--line);border-radius:5px;padding:.1em .36em}
pre{background:var(--panel);border:1px solid var(--line);padding:1rem 1.1rem;
border-radius:var(--r-soft);overflow-x:auto;margin:0 0 1.25rem}
pre code{background:none;border:0;padding:0;font-size:.82rem;line-height:1.7}
blockquote{margin:0 0 1rem;padding-left:1rem;border-left:1px solid var(--line-hi);color:var(--soft)}
hr{border:0;border-top:1px solid var(--line);margin:2.5rem 0}
table{border-collapse:collapse;width:100%;margin:0 0 1.25rem;font-size:.92rem;
display:block;overflow-x:auto}
th,td{border:1px solid var(--line);padding:.5rem .7rem;text-align:left}
.curl{display:block;background:var(--panel);border:1px solid var(--line);
border-radius:var(--r-soft);padding:.95rem 1.1rem;font-family:var(--mono);
font-size:.8rem;color:var(--soft);overflow-x:auto;margin:0 0 2.5rem;
white-space:pre;line-height:1.9}
.curl b{color:var(--ink);font-weight:400}
.curl i{font-style:normal;color:var(--faint)}
/* index */
#q{width:100%;padding:.85rem 1.2rem;font-family:var(--mono);font-size:.85rem;color:var(--ink);
background:var(--panel);border:1px solid var(--line);border-radius:var(--r);margin:0 0 .6rem}
#q::placeholder{color:var(--faint);text-transform:uppercase;letter-spacing:.1em;font-size:.72rem}
#q:focus{outline:none;border-color:var(--soft)}
#count{color:var(--faint);font-family:var(--mono);font-size:.72rem;letter-spacing:.1em;
text-transform:uppercase;margin:0 0 2rem}
.cat{margin:2.5rem 0 .5rem;font-family:var(--mono);font-size:.7rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);border-bottom:1px solid var(--line);
padding-bottom:.45rem}
.row{display:block;padding:.6rem .9rem;margin:0 -.9rem;border-bottom:1px solid var(--line);
border-radius:var(--r-soft);text-decoration:none}
.row:hover{background:#0a0a0a}
.nm{font-family:var(--mono);font-size:.84rem;color:var(--ink);display:block}
.ds{color:var(--soft);font-size:.9rem;display:block;margin-top:.12rem}
footer{margin-top:4rem;padding:2rem 0 4rem;border-top:1px solid var(--line);
color:var(--faint);font-size:.85rem}
footer a{color:var(--soft)}
.fmap{display:grid;gap:1.75rem;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));
margin:0 0 2rem;font-size:.85rem}
.fmap b{display:block;font-family:var(--mono);font-size:.68rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);font-weight:400;margin:0 0 .6rem;
border-bottom:1px solid var(--line);padding-bottom:.4rem}
.fmap a{display:inline-block;color:var(--ink);text-decoration:none;margin:.3rem .35rem 0 0}
.fmap a:hover{text-decoration:underline}
.fmap div{color:var(--faint);line-height:1.5}
.fend{border-top:1px solid var(--line);padding-top:1.25rem;font-size:.82rem}
@media (max-width:640px){
.hero .wrap{padding-top:3.25rem;padding-bottom:2.75rem}
.btns{gap:.5rem}
.btn{padding:.75rem 1.15rem;font-size:.68rem}
.copy,.copy .btn{width:100%;justify-content:center}
.menu{left:0;right:0;min-width:0}
.strip .in{flex-direction:column;align-items:flex-start;gap:.6rem;padding:.9rem 1.75rem}
.strip b{border-right:0;padding-right:0}
.bar{width:100%}
}
</style>
<link rel="alternate" type="text/markdown" href="/engineering-ci-cd-pipelines.md">
<link rel="icon" href="/favicon.svg">
<link rel="canonical" href="https://hanzoskills.com/engineering-ci-cd-pipelines">
</head>
<!-- Reading this with a machine? Every page here is also plain markdown.
This one: https://hanzoskills.com/engineering-ci-cd-pipelines.md
Index: https://hanzoskills.com/llms.txt
Corpus: https://hanzoskills.com/all.md
Append .md to any path for the markdown twin. -->
<body>
<nav><div class="in">
<a class="brand" href="/"><svg class="mark" viewBox="0 0 67 67" fill="currentColor" aria-hidden="true"><path d="M22.21 67V44.6369H0V67H22.21Z"/><path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z"/><path d="M22.21 0H0V22.3184H22.21V0Z"/><path d="M66.7198 0H44.5098V22.3184H66.7198V0Z"/><path d="M66.7198 67V44.6369H44.5098V67H66.7198Z"/></svg> HANZO<i>SKILLS</i></a>
<a class="up" href="/">All skills</a>
</div></nav>
<div class="wrap">
<h1>engineering-ci-cd-pipelines</h1><p class="lede">Comprehensive CI/CD pipeline design covering build, test, security, deployment automation, artifact management, and multi-platform implementation (GitHub Actions, GitLab CI, Jenkins, CircleCI)</p><h1>CI/CD Pipelines</h1>
<p><strong>Scope</strong>: Complete CI/CD pipeline architecture from source to production, including build automation, testing strategies, security scanning, artifact management, deployment patterns, and platform-specific implementations</p>
<p><strong>Lines</strong>: ~850</p>
<p><strong>Last Updated</strong>: 2025-10-27</p>
<p><strong>Format Version</strong>: 1.0 (Atomic)</p>
<hr>
<h2>When to Use This Skill</h2>
<p>Activate this skill when:</p>
<ul><li>Designing or implementing CI/CD pipelines from scratch</li><li>Optimizing existing pipeline performance and reliability</li><li>Implementing security scanning and compliance gates</li><li>Setting up multi-environment deployment workflows</li><li>Managing artifacts and versioning strategies</li><li>Configuring automated testing in pipelines</li><li>Implementing infrastructure as code for pipelines</li><li>Troubleshooting pipeline failures and bottlenecks</li><li>Migrating between CI/CD platforms</li></ul>
<p>Don&#x27;t use this skill for:</p>
<ul><li>Specific deployment strategies (see <code>deployment-strategies.md</code>)</li><li>Kubernetes-specific deployments (see <code>kubernetes-deployment</code>)</li><li>Security-only concerns (see <code>ci-security.md</code>)</li><li>Testing strategies only (see <code>ci-testing-strategy.md</code>)</li></ul>
<hr>
<h2>Core Concepts</h2>
<h3>Concept 1: Pipeline Stages Architecture</h3>
<p><strong>Definition</strong>: Structured progression from code commit to production deployment</p>
<p><strong>Standard Pipeline Stages</strong>:</p>
<pre><code>Source → Build → Test → Security → Package → Deploy → Monitor
↓ ↓ ↓ ↓ ↓ ↓ ↓
SCM Compile Units SAST Artifacts Envs Observe
Bundle Integ DAST Registry Promote Metrics
Assets E2E Vuln Version Health Alerts</code></pre>
<p><strong>Stage Principles</strong>:</p>
<ol><li><strong>Fail Fast</strong>: Run fastest checks first</li><li><strong>Isolation</strong>: Each stage independent and idempotent</li><li><strong>Artifacts</strong>: Build once, deploy many times</li><li><strong>Gates</strong>: Quality gates block bad deployments</li><li><strong>Observability</strong>: Comprehensive logging and metrics</li></ol>
<p><strong>Stage Dependencies</strong>:</p>
<pre><code>Build ← Tests require built artifacts
Tests ← Security scans require dependencies
Package ← Deployment requires tested artifacts
Deploy ← Monitoring validates deployment</code></pre>
<hr>
<h3>Concept 2: Pipeline as Code</h3>
<p><strong>Definition</strong>: Define pipelines in version-controlled declarative configuration</p>
<p><strong>Benefits</strong>:</p>
<pre><code>Version Control: Track changes, review, rollback
Reproducibility: Same config = same pipeline
Code Review: Pipeline changes reviewed like code
Testing: Test pipeline changes in branches
Documentation: Pipeline is self-documenting</code></pre>
<p><strong>Platform Comparison</strong>:</p>
<pre><code>Platform | Language | Features
------------------|----------|------------------
GitHub Actions | YAML | Matrix, reusable workflows
GitLab CI | YAML | Include, extends, DAG
Jenkins | Groovy | Shared libraries, DSL
CircleCI | YAML | Orbs, workflows
Buildkite | YAML | Dynamic pipelines</code></pre>
<hr>
<h3>Concept 3: Artifact Management</h3>
<p><strong>Definition</strong>: Store, version, and distribute build artifacts efficiently</p>
<p><strong>Artifact Strategy</strong>:</p>
<pre><code>Build Once
↓
Tag with metadata (git sha, version, timestamp)
↓
Store in registry (Docker, npm, Maven, PyPI)
↓
Promote through environments
↓
Track provenance and SBOM</code></pre>
<p><strong>Versioning Strategies</strong>:</p>
<ul><li><strong>Semantic</strong>: <code>v1.2.3</code> for releases</li><li><strong>SHA-based</strong>: <code>v1.2.3-abc1234</code> for traceability</li><li><strong>Timestamp</strong>: <code>v1.2.3-20251027-1430</code> for ordering</li><li><strong>Environment</strong>: <code>v1.2.3-staging</code> for promotion</li></ul>
<p><strong>Registry Types</strong>:</p>
<pre><code>Docker: Docker Hub, GHCR, ECR, GCR, ACR
npm/Node: npm registry, GitHub Packages
Python: PyPI, private package index
Java: Maven Central, Artifactory, Nexus
Generic: S3, GCS, Azure Blob</code></pre>
<hr>
<h2>Patterns</h2>
<h3>Pattern 1: GitHub Actions Multi-Stage Pipeline</h3>
<p><strong>Problem</strong>: Need comprehensive pipeline with parallel execution</p>
<p><strong>Implementation</strong>:</p>
<pre><code class="lang-yaml">name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Stage 1: Validate
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate code format
run: npm run lint
- name: Type check
run: npm run typecheck
- name: Check for secrets
uses: gitleaks/gitleaks-action@v2
# Stage 2: Build
build:
needs: validate
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: &#x27;20&#x27;
cache: &#x27;npm&#x27;
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Generate version
id: version
run: |
VERSION=&quot;v$(jq -r .version package.json)-${GITHUB_SHA::8}&quot;
echo &quot;version=$VERSION&quot; &gt;&gt; $GITHUB_OUTPUT
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ steps.version.outputs.version }}
path: dist/
retention-days: 7
# Stage 3: Test (parallel)
test-unit:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: &#x27;20&#x27;
cache: &#x27;npm&#x27;
- run: npm ci
- run: npm run test:unit -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
flags: unit
test-integration:
needs: build
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: &gt;-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: &#x27;20&#x27;
cache: &#x27;npm&#x27;
- run: npm ci
- run: npm run test:integration
env:
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/test
test-e2e:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: &#x27;20&#x27;
cache: &#x27;npm&#x27;
- run: npm ci
- run: npx playwright install --with-deps
- run: npm run test:e2e
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
# Stage 4: Security (parallel)
security-sast:
needs: build
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- name: CodeQL Analysis
uses: github/codeql-action/init@v3
with:
languages: javascript
queries: security-extended
- uses: github/codeql-action/autobuild@v3
- uses: github/codeql-action/analyze@v3
security-dependencies:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: &#x27;20&#x27;
- run: npm audit --audit-level=high
- name: Snyk test
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
# Stage 5: Package
package:
needs: [test-unit, test-integration, test-e2e, security-sast, security-dependencies]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image-tag: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.build.outputs.version }}
path: dist/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,prefix={{branch}}-
type=raw,value=${{ needs.build.outputs.version }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ needs.build.outputs.version }}
COMMIT=${{ github.sha }}
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ steps.meta.outputs.tags }}
format: spdx-json
output-file: sbom.spdx.json
- name: Scan image
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.meta.outputs.tags }}
format: &#x27;sarif&#x27;
output: &#x27;trivy-results.sarif&#x27;
severity: &#x27;CRITICAL,HIGH&#x27;
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: &#x27;trivy-results.sarif&#x27;
# Stage 6: Deploy to Staging
deploy-staging:
needs: package
if: github.ref == &#x27;refs/heads/develop&#x27;
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging.example.com
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_STAGING }}
aws-region: us-east-1
- name: Deploy to ECS
run: |
aws ecs update-service \
--cluster staging-cluster \
--service myapp \
--force-new-deployment
- name: Wait for deployment
run: |
aws ecs wait services-stable \
--cluster staging-cluster \
--services myapp
- name: Smoke tests
run: |
curl -f https://staging.example.com/health
npm run test:smoke -- --baseUrl=https://staging.example.com
# Stage 7: Deploy to Production
deploy-production:
needs: package
if: github.ref == &#x27;refs/heads/main&#x27;
runs-on: ubuntu-latest
environment:
name: production
url: https://example.com
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_PRODUCTION }}
aws-region: us-east-1
- name: Deploy to ECS (canary)
run: |
# Deploy with 10% traffic
./scripts/canary-deploy.sh \
--cluster prod-cluster \
--service myapp \
--image ${{ needs.package.outputs.image-tag }} \
--canary-percent 10
- name: Monitor canary
run: |
# Monitor for 10 minutes
./scripts/monitor-canary.sh \
--duration 600 \
--error-threshold 1.0
- name: Promote canary
run: |
# Shift to 100% traffic
./scripts/promote-canary.sh \
--cluster prod-cluster \
--service myapp
# Stage 8: Notify
notify:
needs: [deploy-staging, deploy-production]
if: always()
runs-on: ubuntu-latest
steps:
- name: Notify Slack
uses: slackapi/slack-github-action@v1
with:
payload: |
{
&quot;text&quot;: &quot;Deployment ${{ needs.deploy-production.result }}&quot;,
&quot;blocks&quot;: [
{
&quot;type&quot;: &quot;section&quot;,
&quot;text&quot;: {
&quot;type&quot;: &quot;mrkdwn&quot;,
&quot;text&quot;: &quot;Deployment to production: *${{ needs.deploy-production.result }}*\nCommit: ${{ github.sha }}\nActor: ${{ github.actor }}&quot;
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}</code></pre>
<p><strong>Benefits</strong>:</p>
<ul><li>Parallel execution reduces pipeline time</li><li>Comprehensive quality gates</li><li>Artifact promotion pattern</li><li>Progressive deployment</li><li>Monitoring and notifications</li></ul>
<hr>
<h3>Pattern 2: GitLab CI Multi-Environment Pipeline</h3>
<p><strong>Problem</strong>: Need complex deployment workflow with manual approvals</p>
<p><strong>Implementation</strong>:</p>
<pre><code class="lang-yaml"># .gitlab-ci.yml
stages:
- validate
- build
- test
- security
- package
- deploy-dev
- deploy-staging
- deploy-production
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: &quot;/certs&quot;
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
# Templates
.build-template: &amp;build-template
image: node:20
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .npm/
before_script:
- npm ci --cache .npm --prefer-offline
.deploy-template: &amp;deploy-template
image: alpine:latest
before_script:
- apk add --no-cache curl
- curl -LO &quot;https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl&quot;
- chmod +x kubectl
- mv kubectl /usr/local/bin/
# Stage: Validate
lint:
stage: validate
&lt;&lt;: *build-template
script:
- npm run lint
- npm run typecheck
rules:
- if: $CI_PIPELINE_SOURCE == &quot;merge_request_event&quot;
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Stage: Build
build:
stage: build
&lt;&lt;: *build-template
script:
- npm run build
- echo &quot;VERSION=$(jq -r .version package.json)-$CI_COMMIT_SHORT_SHA&quot; &gt; version.txt
artifacts:
paths:
- dist/
- version.txt
expire_in: 1 week
rules:
- if: $CI_PIPELINE_SOURCE == &quot;merge_request_event&quot;
- if: $CI_COMMIT_BRANCH
# Stage: Test
test:unit:
stage: test
&lt;&lt;: *build-template
needs: [build]
script:
- npm run test:unit -- --coverage
coverage: &#x27;/All files[^|]*\|[^|]*\s+([\d\.]+)/&#x27;
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
test:integration:
stage: test
&lt;&lt;: *build-template
needs: [build]
services:
- name: postgres:16
alias: postgres
variables:
POSTGRES_DB: test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
DATABASE_URL: postgresql://test:test@postgres:5432/test
script:
- npm run test:integration
test:e2e:
stage: test
&lt;&lt;: *build-template
needs: [build]
script:
- npx playwright install --with-deps
- npm run test:e2e
artifacts:
when: on_failure
paths:
- playwright-report/
expire_in: 7 days
# Stage: Security
security:sast:
stage: security
needs: [build]
image: returntocorp/semgrep
script:
- semgrep --config=auto --sarif &gt; gl-sast-report.json
artifacts:
reports:
sast: gl-sast-report.json
security:dependency:
stage: security
needs: [build]
&lt;&lt;: *build-template
script:
- npm audit --audit-level=moderate
allow_failure: true
security:secrets:
stage: security
image: zricethezav/gitleaks
script:
- gitleaks detect --verbose --no-git
allow_failure: false
# Stage: Package
docker:build:
stage: package
image: docker:24
services:
- docker:24-dind
needs:
- build
- test:unit
- test:integration
- test:e2e
- security:sast
- security:dependency
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build
--build-arg VERSION=$(cat version.txt)
--build-arg COMMIT=$CI_COMMIT_SHA
--tag $IMAGE_TAG
--tag $CI_REGISTRY_IMAGE:latest
.
- docker push $IMAGE_TAG
- docker push $CI_REGISTRY_IMAGE:latest
# Scan image
- apk add --no-cache curl
⚠️ **SECURITY**: Piping curl to shell is dangerous. For production:
- curl -O https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh
- sha256sum install.sh
- less install.sh
- sh install.sh -b /usr/local/bin
# For development/learning only:
- curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
- trivy image --exit-code 0 --severity HIGH,CRITICAL $IMAGE_TAG
# Generate SBOM
⚠️ **SECURITY**: Piping curl to shell is dangerous. For production:
- curl -O https://raw.githubusercontent.com/anchore/syft/main/install.sh
- sha256sum install.sh
- less install.sh
- sh install.sh -b /usr/local/bin
# For development/learning only:
- curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- syft $IMAGE_TAG -o spdx-json &gt; sbom.spdx.json
artifacts:
paths:
- sbom.spdx.json
expire_in: 30 days
rules:
- if: $CI_COMMIT_BRANCH
# Stage: Deploy Development
deploy:dev:
stage: deploy-dev
&lt;&lt;: *deploy-template
needs: [docker:build]
environment:
name: development
url: https://dev.example.com
on_stop: stop:dev
script:
- kubectl config use-context dev-cluster
- kubectl set image deployment/myapp myapp=$IMAGE_TAG -n dev
- kubectl rollout status deployment/myapp -n dev
- curl -f https://dev.example.com/health
rules:
- if: $CI_COMMIT_BRANCH == &quot;develop&quot;
stop:dev:
stage: deploy-dev
&lt;&lt;: *deploy-template
environment:
name: development
action: stop
script:
- kubectl delete deployment myapp -n dev
when: manual
rules:
- if: $CI_COMMIT_BRANCH == &quot;develop&quot;
# Stage: Deploy Staging
deploy:staging:
stage: deploy-staging
&lt;&lt;: *deploy-template
needs: [docker:build]
environment:
name: staging
url: https://staging.example.com
script:
- kubectl config use-context staging-cluster
- |
cat &lt;&lt;EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: staging
spec:
replicas: 2
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
version: $CI_COMMIT_SHORT_SHA
spec:
containers:
- name: myapp
image: $IMAGE_TAG
ports:
- containerPort: 8080
env:
- name: ENVIRONMENT
value: staging
readinessProbe:
httpGet:
path: /ready
port: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
EOF
- kubectl rollout status deployment/myapp -n staging
- sleep 30
- curl -f https://staging.example.com/health
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Stage: Deploy Production
deploy:production:
stage: deploy-production
&lt;&lt;: *deploy-template
needs: [deploy:staging]
environment:
name: production
url: https://example.com
script:
- kubectl config use-context production-cluster
# Blue-green deployment
- export CURRENT_COLOR=$(kubectl get service myapp -n prod -o jsonpath=&#x27;{.spec.selector.color}&#x27;)
- export NEW_COLOR=$(if [ &quot;$CURRENT_COLOR&quot; = &quot;blue&quot; ]; then echo &quot;green&quot;; else echo &quot;blue&quot;; fi)
# Deploy new version
- kubectl set image deployment/myapp-$NEW_COLOR myapp=$IMAGE_TAG -n prod
- kubectl rollout status deployment/myapp-$NEW_COLOR -n prod
# Health check
- kubectl run curl-test --image=curlimages/curl --rm -it --restart=Never -- curl -f http://myapp-$NEW_COLOR.prod.svc.cluster.local/health
# Switch traffic
- kubectl patch service myapp -n prod -p &#x27;{&quot;spec&quot;:{&quot;selector&quot;:{&quot;color&quot;:&quot;&#x27;$NEW_COLOR&#x27;&quot;}}}&#x27;
# Monitor for 5 minutes
- sleep 300
# Verify success
- curl -f https://example.com/health
- echo &quot;Deployment successful. Old color $CURRENT_COLOR, new color $NEW_COLOR&quot;
when: manual
only:
- main</code></pre>
<p><strong>Benefits</strong>:</p>
<ul><li>GitLab-native features (includes, artifacts, environments)</li><li>Manual approval gates for production</li><li>Blue-green deployment pattern</li><li>Comprehensive testing and security</li><li>Multi-cluster deployment</li></ul>
<hr>
<h3>Pattern 3: Jenkins Declarative Pipeline</h3>
<p><strong>Problem</strong>: Need flexible pipeline with shared libraries</p>
<p><strong>Implementation</strong>:</p>
<pre><code class="lang-groovy">// Jenkinsfile
@Library(&#x27;shared-pipeline-library&#x27;) _
pipeline {
agent {
kubernetes {
yaml &quot;&quot;&quot;
apiVersion: v1
kind: Pod
spec:
containers:
- name: node
image: node:20
command: [&#x27;cat&#x27;]
tty: true
- name: docker
image: docker:24
command: [&#x27;cat&#x27;]
tty: true
volumeMounts:
- name: docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
&quot;&quot;&quot;
}
}
environment {
DOCKER_REGISTRY = &#x27;registry.example.com&#x27;
IMAGE_NAME = &quot;${DOCKER_REGISTRY}/myapp&quot;
VERSION = sh(script: &quot;echo v\$(cat package.json | jq -r .version)-\${GIT_COMMIT[0..7]}&quot;, returnStdout: true).trim()
}
options {
buildDiscarder(logRotator(numToKeepStr: &#x27;30&#x27;))
timeout(time: 1, unit: &#x27;HOURS&#x27;)
timestamps()
disableConcurrentBuilds()
}
parameters {
booleanParam(name: &#x27;DEPLOY_TO_PRODUCTION&#x27;, defaultValue: false, description: &#x27;Deploy to production?&#x27;)
choice(name: &#x27;ENVIRONMENT&#x27;, choices: [&#x27;dev&#x27;, &#x27;staging&#x27;, &#x27;production&#x27;], description: &#x27;Target environment&#x27;)
}
stages {
stage(&#x27;Checkout&#x27;) {
steps {
checkout scm
sh &#x27;git clean -fdx&#x27;
}
}
stage(&#x27;Validate&#x27;) {
parallel {
stage(&#x27;Lint&#x27;) {
steps {
container(&#x27;node&#x27;) {
sh &#x27;npm ci&#x27;
sh &#x27;npm run lint&#x27;
sh &#x27;npm run typecheck&#x27;
}
}
}
stage(&#x27;Secret Scan&#x27;) {
steps {
sh &#x27;docker run --rm -v $(pwd):/repo zricethezav/gitleaks:latest detect --source /repo --no-git&#x27;
}
}
}
}
stage(&#x27;Build&#x27;) {
steps {
container(&#x27;node&#x27;) {
sh &#x27;npm ci&#x27;
sh &#x27;npm run build&#x27;
stash includes: &#x27;dist/**&#x27;, name: &#x27;build-artifacts&#x27;
}
}
}
stage(&#x27;Test&#x27;) {
parallel {
stage(&#x27;Unit Tests&#x27;) {
steps {
container(&#x27;node&#x27;) {
sh &#x27;npm run test:unit -- --coverage&#x27;
junit &#x27;test-results/junit.xml&#x27;
publishCoverage adapters: [
coberturaAdapter(&#x27;coverage/cobertura-coverage.xml&#x27;)
]
}
}
}
stage(&#x27;Integration Tests&#x27;) {
steps {
container(&#x27;node&#x27;) {
sh &#x27;&#x27;&#x27;
docker run -d --name postgres-test \
-e POSTGRES_PASSWORD=test \
-p 5432:5432 postgres:16
sleep 5
export DATABASE_URL=postgresql://postgres:test@localhost:5432/test
npm run test:integration
docker stop postgres-test
docker rm postgres-test
&#x27;&#x27;&#x27;
}
}
}
stage(&#x27;E2E Tests&#x27;) {
steps {
container(&#x27;node&#x27;) {
sh &#x27;npx playwright install --with-deps&#x27;
sh &#x27;npm run test:e2e&#x27;
}
}
post {
failure {
archiveArtifacts artifacts: &#x27;playwright-report/**&#x27;, allowEmptyArchive: true
}
}
}
}
}
stage(&#x27;Security Scan&#x27;) {
parallel {
stage(&#x27;Dependency Scan&#x27;) {
steps {
container(&#x27;node&#x27;) {
sh &#x27;npm audit --audit-level=moderate || true&#x27;
sh &#x27;npx snyk test --severity-threshold=high || true&#x27;
}
}
}
stage(&#x27;SAST&#x27;) {
steps {
sh &#x27;docker run --rm -v $(pwd):/src returntocorp/semgrep semgrep --config=auto --sarif /src&#x27;
}
}
}
}
stage(&#x27;Package&#x27;) {
steps {
container(&#x27;docker&#x27;) {
unstash &#x27;build-artifacts&#x27;
script {
def image = docker.build(&quot;${IMAGE_NAME}:${VERSION}&quot;,
&quot;--build-arg VERSION=${VERSION} &quot; +
&quot;--build-arg COMMIT=${GIT_COMMIT} .&quot;)
docker.withRegistry(&quot;https://${DOCKER_REGISTRY}&quot;, &#x27;docker-registry-credentials&#x27;) {
image.push(&quot;${VERSION}&quot;)
image.push(&#x27;latest&#x27;)
}
// Scan image
sh &quot;trivy image --exit-code 0 --severity HIGH,CRITICAL ${IMAGE_NAME}:${VERSION}&quot;
// Generate SBOM
sh &quot;syft ${IMAGE_NAME}:${VERSION} -o spdx-json &gt; sbom.spdx.json&quot;
archiveArtifacts artifacts: &#x27;sbom.spdx.json&#x27;, fingerprint: true
}
}
}
}
stage(&#x27;Deploy to Development&#x27;) {
when {
branch &#x27;develop&#x27;
}
steps {
deployToEnvironment(&#x27;dev&#x27;, VERSION)
}
}
stage(&#x27;Deploy to Staging&#x27;) {
when {
branch &#x27;main&#x27;
}
steps {
deployToEnvironment(&#x27;staging&#x27;, VERSION)
// Run smoke tests
sh &quot;curl -f https://staging.example.com/health&quot;
}
}
stage(&#x27;Deploy to Production&#x27;) {
when {
allOf {
branch &#x27;main&#x27;
expression { params.DEPLOY_TO_PRODUCTION == true }
}
}
steps {
input message: &#x27;Deploy to production?&#x27;, ok: &#x27;Deploy&#x27;
deployToEnvironment(&#x27;production&#x27;, VERSION)
// Canary deployment with monitoring
script {
sh &quot;&quot;&quot;
kubectl set image deployment/myapp-canary myapp=${IMAGE_NAME}:${VERSION} -n prod
kubectl rollout status deployment/myapp-canary -n prod
# Monitor for 10 minutes
sleep 600
# Check error rate
ERROR_RATE=\$(curl -s http://prometheus:9090/api/v1/query?query=rate(http_requests_total{status=~&quot;5..&quot;}[5m]) | jq -r &#x27;.data.result[0].value[1]&#x27;)
if (( \$(echo &quot;\$ERROR_RATE &gt; 0.01&quot; | bc -l) )); then
echo &quot;Error rate too high: \$ERROR_RATE&quot;
kubectl rollout undo deployment/myapp-canary -n prod
exit 1
fi
# Promote to full deployment
kubectl set image deployment/myapp myapp=${IMAGE_NAME}:${VERSION} -n prod
kubectl rollout status deployment/myapp -n prod
&quot;&quot;&quot;
}
}
}
}
post {
always {
cleanWs()
}
success {
slackSend(
color: &#x27;good&#x27;,
message: &quot;SUCCESS: ${env.JOB_NAME} #${env.BUILD_NUMBER} (&lt;${env.BUILD_URL}|Open&gt;)&quot;
)
}
failure {
slackSend(
color: &#x27;danger&#x27;,
message: &quot;FAILURE: ${env.JOB_NAME} #${env.BUILD_NUMBER} (&lt;${env.BUILD_URL}|Open&gt;)&quot;
)
}
}
}
// Helper function
def deployToEnvironment(env, version) {
sh &quot;&quot;&quot;
kubectl config use-context ${env}-cluster
kubectl set image deployment/myapp myapp=${IMAGE_NAME}:${version} -n ${env}
kubectl rollout status deployment/myapp -n ${env}
kubectl get pods -n ${env} -l app=myapp
&quot;&quot;&quot;
}</code></pre>
<p><strong>Benefits</strong>:</p>
<ul><li>Kubernetes-based agents</li><li>Shared library functions</li><li>Parallel execution</li><li>Manual approval gates</li><li>Comprehensive notifications</li></ul>
<hr>
<h2>Anti-Patterns</h2>
<h3>Anti-Pattern 1: Testing Without Artifacts</h3>
<p><strong>Problem</strong>: Re-building code in test stages</p>
<p><strong>Why It&#x27;s Bad</strong>:</p>
<ul><li>Wastes time rebuilding</li><li>Tests different code than what deploys</li><li>Non-deterministic results</li><li>Longer pipeline duration</li></ul>
<p><strong>Solution</strong>:</p>
<pre><code class="lang-yaml"># Build once
build:
script: npm run build
artifacts:
paths: [dist/]
# Test using artifacts
test:
needs: [build]
script:
- download artifacts
- npm test</code></pre>
<hr>
<h3>Anti-Pattern 2: No Pipeline Caching</h3>
<p><strong>Problem</strong>: Installing dependencies every run</p>
<p><strong>Why It&#x27;s Bad</strong>:</p>
<ul><li>Slow pipeline execution</li><li>Network dependency</li><li>Wastes resources</li><li>Unpredictable timing</li></ul>
<p><strong>Solution</strong>:</p>
<pre><code class="lang-yaml"># GitHub Actions
- uses: actions/setup-node@v4
with:
cache: &#x27;npm&#x27;
# GitLab CI
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .npm/</code></pre>
<hr>
<h3>Anti-Pattern 3: Secrets in Code</h3>
<p><strong>Problem</strong>: Hardcoded credentials in pipeline configs</p>
<p><strong>Why It&#x27;s Bad</strong>:</p>
<ul><li>Security risk</li><li>Leaked in version control</li><li>Difficult to rotate</li><li>Compliance violations</li></ul>
<p><strong>Solution</strong>:</p>
<pre><code class="lang-yaml"># Use secret management
env:
API_KEY: ${{ secrets.API_KEY }}
# Use OIDC for cloud providers
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}</code></pre>
<hr>
<h3>Anti-Pattern 4: No Version Tagging</h3>
<p><strong>Problem</strong>: Deploying &quot;latest&quot; tag</p>
<p><strong>Why It&#x27;s Bad</strong>:</p>
<ul><li>Can&#x27;t rollback</li><li>No traceability</li><li>Overwrites existing images</li><li>Breaks reproducibility</li></ul>
<p><strong>Solution</strong>:</p>
<pre><code class="lang-yaml"># Semantic versioning with git sha
VERSION: v1.2.3-abc1234
IMAGE_TAG: myapp:v1.2.3-abc1234
# Tag multiple
tags:
- myapp:v1.2.3-abc1234
- myapp:v1.2.3
- myapp:latest</code></pre>
<hr>
<h3>Anti-Pattern 5: Sequential-Only Execution</h3>
<p><strong>Problem</strong>: Running all jobs sequentially</p>
<p><strong>Why It&#x27;s Bad</strong>:</p>
<ul><li>Very slow pipelines</li><li>Wastes CI resources</li><li>Poor developer experience</li><li>Delayed feedback</li></ul>
<p><strong>Solution</strong>:</p>
<pre><code class="lang-yaml"># Parallel stages
test-unit:
needs: [build]
test-integration:
needs: [build]
test-e2e:
needs: [build]
# All run in parallel</code></pre>
<hr>
<h2>Quick Reference</h2>
<h3>Pipeline Performance Optimization</h3>
<pre><code class="lang-yaml">Caching: Cache dependencies (npm, pip, maven)
Parallelization: Run independent jobs in parallel
Artifacts: Build once, reuse everywhere
Docker layers: Multi-stage builds, layer caching
Matrix builds: Test multiple versions simultaneously
Conditional: Skip unnecessary jobs</code></pre>
<h3>Common Pipeline Metrics</h3>
<pre><code class="lang-yaml">Lead Time: Commit to production
Build Time: Duration of build stage
Test Time: Duration of all tests
Deployment Time: Time to deploy
Failure Rate: % of failed pipelines
MTTR: Mean time to recovery</code></pre>
<h3>Security Scanning Tools</h3>
<pre><code class="lang-yaml">SAST: CodeQL, Semgrep, SonarQube
Dependency: npm audit, Snyk, Dependabot
Container: Trivy, Grype, Snyk Container
Secrets: Gitleaks, TruffleHog
License: license-checker, FOSSA
SBOM: Syft, CycloneDX</code></pre>
<hr>
<h2>Level 3: Resources</h2>
<p><strong>Extended documentation, production-ready scripts, and complete examples</strong></p>
<h3>REFERENCE.md</h3>
<p><strong>Location</strong>: <code>resources/REFERENCE.md</code> (3,847 lines)</p>
<p>Comprehensive reference covering:</p>
<ul><li>CI/CD fundamentals and architecture patterns</li><li>Platform-specific implementations (GitHub Actions, GitLab CI, Jenkins, CircleCI, Buildkite)</li><li>Pipeline optimization strategies (caching, parallelization, artifacts)</li><li>Testing integration (unit, integration, E2E, security)</li><li>Security scanning and compliance (SAST, DAST, SCA, secrets)</li><li>Artifact management and versioning strategies</li><li>Multi-environment deployment workflows</li><li>Monitoring and observability in pipelines</li><li>Troubleshooting and debugging techniques</li><li>Migration guides between platforms</li><li>Complete production examples for all patterns</li></ul>
<h3>Scripts</h3>
<p><strong>validate_pipeline.py</strong> (782 lines) Validates pipeline configurations across multiple platforms:</p>
<pre><code class="lang-bash"># Validate GitHub Actions workflow
./validate_pipeline.py --file .github/workflows/ci.yml --platform github-actions
# Validate GitLab CI
./validate_pipeline.py --file .gitlab-ci.yml --platform gitlab
# Check entire directory
./validate_pipeline.py --directory .github/workflows/ --platform github-actions
# JSON output for CI integration
./validate_pipeline.py --file ci.yml --json</code></pre>
<p><strong>analyze_pipeline_performance.py</strong> (698 lines) Analyzes pipeline performance and identifies bottlenecks:</p>
<pre><code class="lang-bash"># Analyze GitHub Actions workflows
./analyze_pipeline_performance.py --platform github-actions --repo owner/repo
# Compare multiple runs
./analyze_pipeline_performance.py --runs 100 --compare
# Generate optimization report
./analyze_pipeline_performance.py --output report.html --recommendations
# JSON output
./analyze_pipeline_performance.py --json</code></pre>
<p><strong>test_pipeline.sh</strong> (656 lines) Tests pipeline configurations and deployment procedures:</p>
<pre><code class="lang-bash"># Dry-run pipeline locally
./test_pipeline.sh --file .github/workflows/ci.yml --dry-run
# Test deployment scripts
./test_pipeline.sh --test-deployment --environment staging
# Validate rollback procedures
./test_pipeline.sh --test-rollback
# Full pipeline simulation
./test_pipeline.sh --simulate --verbose</code></pre>
<h3>Production Examples</h3>
<p><strong>Complete Multi-Platform Pipelines</strong>:</p>
<ul><li><code>examples/github-actions/complete-pipeline.yml</code>: Full GitHub Actions pipeline with all stages</li><li><code>examples/gitlab-ci/complete-pipeline.yml</code>: Full GitLab CI pipeline with environments</li><li><code>examples/jenkins/Jenkinsfile</code>: Complete Jenkins declarative pipeline</li><li><code>examples/circleci/config.yml</code>: CircleCI pipeline with workflows and orbs</li></ul>
<p><strong>Deployment Automation</strong>:</p>
<ul><li><code>examples/deployment/kubernetes-deploy.yml</code>: Kubernetes deployment automation</li><li><code>examples/deployment/aws-ecs-deploy.yml</code>: AWS ECS deployment</li><li><code>examples/deployment/azure-deploy.yml</code>: Azure App Service deployment</li><li><code>examples/deployment/gcp-deploy.yml</code>: Google Cloud Run deployment</li></ul>
<p><strong>Security Integration</strong>:</p>
<ul><li><code>examples/security/trivy-scan.yml</code>: Container scanning with Trivy</li><li><code>examples/security/snyk-integration.yml</code>: Snyk security scanning</li><li><code>examples/security/codeql-analysis.yml</code>: CodeQL SAST integration</li></ul>
<p><strong>Artifact Management</strong>:</p>
<ul><li><code>examples/artifacts/docker-registry.yml</code>: Docker image management</li><li><code>examples/artifacts/npm-publish.yml</code>: NPM package publishing</li><li><code>examples/artifacts/versioning-strategy.yml</code>: Semantic versioning automation</li></ul>
<p>All examples include:</p>
<ul><li>Production-ready configurations</li><li>Comprehensive comments and documentation</li><li>Error handling and validation</li><li>Security best practices</li><li>Performance optimizations</li><li>Monitoring integration</li></ul>
<hr>
<h2>Related Skills</h2>
<ul><li><code>deployment-strategies.md</code> - Blue-green, canary, rolling deployments</li><li><code>ci-security.md</code> - Security scanning and secret management</li><li><code>ci-testing-strategy.md</code> - Test execution patterns</li><li><code>ci-optimization.md</code> - Pipeline performance tuning</li><li><code>kubernetes-deployment</code> - K8s-specific deployments</li><li><code>docker-best-practices</code> - Container optimization</li></ul>
<hr>
<p><strong>Last Updated</strong>: 2025-10-27 <strong>Maintainer</strong>: Skills Team <strong>Validation</strong>: CI-validated, production-tested patterns</p>
<footer>
<div class="fmap">
<div><b>Build</b>
<a href="https://hanzo.app">hanzo.app</a> app builder
<a href="https://hanzo.codes">hanzo.codes</a> code with an agent
<a href="https://hanzoskills.com">hanzoskills.com</a> what an agent reads</div>
<div><b>Run</b>
<a href="https://console.hanzo.ai">console.hanzo.ai</a> cloud console
<a href="https://api.hanzo.ai">api.hanzo.ai</a> the API</div>
<div><b>Account</b>
<a href="https://hanzo.id">hanzo.id</a> sign in
<a href="https://pay.hanzo.ai">pay.hanzo.ai</a> top up
<a href="https://billing.hanzo.ai">billing.hanzo.ai</a> invoices and usage</div>
<div><b>Company</b>
<a href="https://hanzo.ai">hanzo.ai</a> canonical
<a href="https://hanzo.ventures">hanzo.ventures</a> ventures</div>
</div>
<div class="fend"><a href="/engineering-ci-cd-pipelines.md">This page as plain text</a> · <a href="/llms.txt">Index for agents</a></div>
</footer>
</div></body></html>