Integrate restricted staging verification into Chapter 6 delivery pipeline
startup-product-gitea-ci/pipeline/pr-main There was a failure building this commit
startup-product-gitea-ci/pipeline/pr-main There was a failure building this commit
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent { label 'chapter6-mac-agent-secure' }
|
||||||
|
|
||||||
options {
|
options {
|
||||||
disableConcurrentBuilds()
|
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') {
|
stage('Verify Node.js') {
|
||||||
steps {
|
steps {
|
||||||
sh 'node --version'
|
sh 'node --version'
|
||||||
@@ -48,36 +59,53 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
set -eu
|
set -eu
|
||||||
export UV_CACHE_DIR=/var/jenkins_home/.cache/uv
|
export PATH=/opt/homebrew/bin:$PATH
|
||||||
/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 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 {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
set -eu
|
set -eu
|
||||||
curl -fsS --max-time 10 http://startup-pricing-staging:5000/health -o /tmp/pricing-health.json
|
export PATH=/opt/homebrew/bin:$PATH
|
||||||
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")'
|
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 {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
set -eu
|
set -eu
|
||||||
curl -fsS --max-time 10 http://startup-pricing-staging:5000/pricing -o /tmp/pricing-response.json
|
date -u
|
||||||
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")'
|
|
||||||
|
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') {
|
stage('Production Approval') {
|
||||||
steps {
|
steps {
|
||||||
timeout(time: 30, unit: 'MINUTES') {
|
timeout(time: 30, unit: 'MINUTES') {
|
||||||
input message: 'Approve Chapter 6 production promotion?',
|
input message: 'Approve Chapter 6 production promotion?',
|
||||||
ok: 'Approve Production',
|
ok: 'Approve Production',
|
||||||
submitter: 'cyberbot',
|
submitter: 'chapter6-approver',
|
||||||
submitterParameter: 'APPROVED_BY'
|
submitterParameter: 'APPROVED_BY'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user