docs: restore SRE chapter and integrate secure delivery chapter 6 #13
@@ -1,6 +1,6 @@
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
agent { label 'chapter6-mac-agent-secure' }
|
||||
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
@@ -15,6 +15,17 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Secret Security Gate') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
export PATH=/opt/homebrew/bin:$PATH
|
||||
gitleaks version
|
||||
gitleaks git . --redact=100 --exit-code 42
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Verify Node.js') {
|
||||
steps {
|
||||
sh 'node --version'
|
||||
@@ -48,36 +59,53 @@ pipeline {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
export UV_CACHE_DIR=/var/jenkins_home/.cache/uv
|
||||
/var/jenkins_home/.local/bin/uv tool run --from pip-audit==2.10.1 pip-audit --disable-pip -r pricing-service/requirements-production.lock.txt
|
||||
export PATH=/opt/homebrew/bin:$PATH
|
||||
export UV_CACHE_DIR="$WORKSPACE/.uv-cache"
|
||||
uv tool run --from pip-audit==2.10.1 pip-audit --disable-pip -r pricing-service/requirements-production.lock.txt
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Staging Health Check') {
|
||||
stage('Container Security Gate') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
curl -fsS --max-time 10 http://startup-pricing-staging:5000/health -o /tmp/pricing-health.json
|
||||
python3 -c 'import json; data=json.load(open("/tmp/pricing-health.json")); assert data["status"] == "healthy"; assert data["version"] == "v2"; print("Staging health check PASSED")'
|
||||
export PATH=/opt/homebrew/bin:$PATH
|
||||
trivy image --platform linux/amd64 --scanners vuln --severity HIGH,CRITICAL --exit-code 1 --format table --output trivy-report.txt git.nageshwaran.dev/ssw590-startup/startup-pricing@sha256:14d520f6fbe60c9cc5e661551a03e944de3a2ad777a64c316ec397ee765db22d
|
||||
'''
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts artifacts: 'trivy-report.txt', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Staging Pricing Smoke Test') {
|
||||
stage('Staging Verification and Smoke Tests') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
curl -fsS --max-time 10 http://startup-pricing-staging:5000/pricing -o /tmp/pricing-response.json
|
||||
python3 -c 'import json; data=json.load(open("/tmp/pricing-response.json")); assert data["version"] == "v2"; actual={p["name"]:p["price"] for p in data["plans"]}; assert actual == {"Starter":5,"Basic":12,"Pro":30,"Enterprise":60}; print("Pricing smoke test PASSED")'
|
||||
date -u
|
||||
|
||||
ssh -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o ConnectTimeout=10 -i "$HOME/.ssh/chapter6_deploy" chapter6deploy@git.nageshwaran.dev verify-staging > staging-verification.txt
|
||||
|
||||
cat staging-verification.txt
|
||||
|
||||
python3 -c 'import json; lines=open("staging-verification.txt").read().splitlines(); data=[json.loads(x) for x in lines if x.startswith("{")]; assert len(data)==2; assert data[0]["status"]=="healthy"; assert data[0]["version"]=="v2"; assert data[1]["version"]=="v2"; assert {p["name"]:p["price"] for p in data[1]["plans"]}=={"Starter":5,"Basic":12,"Pro":30,"Enterprise":60}; print("SUCCESS: All staging smoke tests passed")'
|
||||
'''
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts artifacts: 'staging-verification.txt', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Production Approval') {
|
||||
steps {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
input message: 'Approve Chapter 6 production promotion?',
|
||||
ok: 'Approve Production',
|
||||
submitter: 'cyberbot',
|
||||
submitter: 'chapter6-approver',
|
||||
submitterParameter: 'APPROVED_BY'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user