startup-product-gitea-ci/pipeline/pr-main There was a failure building this commit
126 lines
3.9 KiB
Plaintext
126 lines
3.9 KiB
Plaintext
|
|
pipeline {
|
|
agent { label 'chapter6-mac-agent-secure' }
|
|
|
|
options {
|
|
disableConcurrentBuilds()
|
|
timeout(time: 60, unit: 'MINUTES')
|
|
buildDiscarder(logRotator(numToKeepStr: '5'))
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
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'
|
|
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 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('Container Security Gate') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
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 Verification and Smoke Tests') {
|
|
steps {
|
|
sh '''
|
|
set -eu
|
|
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: 'chapter6-approver',
|
|
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.'
|
|
}
|
|
}
|
|
}
|