From dfbf5488d04277c01d7b5e1c4c401199dc6cce7c Mon Sep 17 00:00:00 2001 From: Nageshwaran Manikumar Date: Mon, 23 Nov 2026 04:20:48 -0500 Subject: [PATCH] Chapter 6: add separate delivery pipeline with dependency audit and approval --- Jenkinsfile.chapter6-delivery | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 Jenkinsfile.chapter6-delivery diff --git a/Jenkinsfile.chapter6-delivery b/Jenkinsfile.chapter6-delivery new file mode 100644 index 0000000..99086be --- /dev/null +++ b/Jenkinsfile.chapter6-delivery @@ -0,0 +1,97 @@ + +pipeline { + agent any + + options { + disableConcurrentBuilds() + timeout(time: 60, unit: 'MINUTES') + buildDiscarder(logRotator(numToKeepStr: '5')) + } + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Verify Node.js') { + steps { + sh 'node --version' + sh 'npm --version' + } + } + + stage('Syntax Check') { + steps { + dir('app') { + sh 'npm run check' + } + } + } + + stage('Automated Tests') { + steps { + dir('app') { + sh 'npm test' + } + } + } + + stage('Verify Python') { + steps { + sh 'python3 --version' + } + } + + stage('Dependency Security Audit') { + 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 + ''' + } + } + stage('Staging Health Check') { + 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")' + ''' + } + } + + stage('Staging Pricing Smoke Test') { + 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")' + ''' + } + } + stage('Production Approval') { + steps { + timeout(time: 30, unit: 'MINUTES') { + input message: 'Approve Chapter 6 production promotion?', + ok: 'Approve Production', + submitter: 'cyberbot', + submitterParameter: 'APPROVED_BY' + } + } + } + + } + + post { + success { + echo 'CI PASSED: Node.js tests and staging smoke tests completed.' + } + + failure { + echo 'CI FAILED: Review the Jenkins console output.' + } + } +}