pipeline { agent { docker { image 'python:3.11-slim' } } environment { APP_PORT = '3001' } stages { stage('Install Dependencies') { steps { sh ''' python --version pip install --upgrade pip pip install -r requirements.txt ''' } } stage('Unit Tests') { steps { sh 'pytest test_app.py' } } stage('Run & Integration Test') { parallel { stage('Start App') { steps { sh ''' gunicorn --bind 0.0.0.0:${APP_PORT} app:app & echo $! > gunicorn.pid ''' } } stage('Integration Test') { steps { sh ''' sleep 5 curl -f http://localhost:${APP_PORT} ''' } } } post { always { sh ''' if [ -f gunicorn.pid ]; then kill $(cat gunicorn.pid) || true fi ''' } } } stage('Containerization') { steps { echo 'Docker Build Image...' echo 'Docker Tag Image...' echo 'Docker Push Image...' } } } }