pipeline { agent any options { disableConcurrentBuilds() skipDefaultCheckout(true) timeout(time: 10, unit: 'MINUTES') buildDiscarder(logRotator( numToKeepStr: '5', artifactNumToKeepStr: '3' )) } stages { stage('Checkout') { steps { checkout scm sh 'git log -1 --oneline' } } stage('Verify Build Tools') { steps { sh ''' node --version npm --version python3 --version ''' } } stage('JavaScript Validation') { steps { dir('app') { sh 'npm run check' } } } stage('JavaScript Unit Tests') { steps { dir('app') { sh 'npm test' } } } stage('Python Validation') { steps { dir('pricing-service') { sh ''' python3 -m py_compile app.py test_app.py echo "Python syntax validation PASSED" ''' } } } stage('Python Unit Tests') { steps { dir('pricing-service') { sh ''' set -eu export PYTHONPATH=/var/jenkins_home/final-project-python-deps export PYTHONDONTWRITEBYTECODE=1 python3 -m unittest -v test_app echo "Python unit tests PASSED" ''' } } } stage('Versioned Package') { steps { sh ''' set -eu VERSION="1.0.${BUILD_NUMBER}" rm -rf dist mkdir -p dist printf '%s\\n' "$VERSION" > dist/VERSION git rev-parse HEAD > dist/COMMIT python3 -m zipfile -c \ "dist/startup-product-${VERSION}.zip" \ app/package.json \ app/src \ app/test \ pricing-service/app.py \ pricing-service/test_app.py \ pricing-service/requirements.txt \ pricing-service/Dockerfile \ dist/VERSION \ dist/COMMIT echo "Package version: $VERSION" ls -lh dist/ ''' } } stage('Verify Package Integrity') { steps { sh ''' set -eu python3 -m zipfile -t \ "dist/startup-product-1.0.${BUILD_NUMBER}.zip" echo "Package integrity PASSED" ''' } } stage('Archive Artifacts') { steps { archiveArtifacts( artifacts: 'dist/*', fingerprint: true, onlyIfSuccessful: true ) } } } post { success { echo 'FINAL PROJECT BASELINE BUILD PASSED' } failure { echo 'FINAL PROJECT BASELINE BUILD FAILED' } always { echo "Build number: ${env.BUILD_NUMBER}" echo "Build URL: ${env.BUILD_URL}" } } }